FrostByte/server/migrations/0002_posts_table.sql

12 lines
499 B
MySQL
Raw Normal View History

2023-10-10 00:03:04 +02:00
CREATE TABLE IF NOT EXISTS posts (
2023-10-20 20:57:58 +02:00
id INTEGER PRIMARY KEY NOT NULL,
user_id INTEGER NOT NULL,
2023-10-10 00:03:04 +02:00
content TEXT NOT NULL,
2023-10-20 06:06:55 +02:00
upvotes INT NOT NULL DEFAULT 0,
downvotes INT NOT NULL DEFAULT 0,
2023-10-10 00:03:04 +02:00
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users (id)
);
create index IF NOT EXISTS posts_user_id_index on posts (user_id);
create index IF NOT EXISTS posts_id_index on posts (id);