Database integration WIP
This commit is contained in:
parent
f3e5cd62b1
commit
2bcda34f6a
13 changed files with 225 additions and 37 deletions
9
server/migrations/0001_users_table.sql
Normal file
9
server/migrations/0001_users_table.sql
Normal file
|
@ -0,0 +1,9 @@
|
|||
CREATE TABLE IF NOT EXISTS users (
|
||||
id SERIAL PRIMARY KEY,
|
||||
username TEXT NOT NULL,
|
||||
password TEXT NOT NULL,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
create index users_username_index on users (username);
|
10
server/migrations/0002_posts_table.sql
Normal file
10
server/migrations/0002_posts_table.sql
Normal file
|
@ -0,0 +1,10 @@
|
|||
CREATE TABLE IF NOT EXISTS posts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
user_id SERIAL NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
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);
|
Loading…
Add table
Add a link
Reference in a new issue