Database integration WIP

This commit is contained in:
Imbus 2023-10-10 00:03:04 +02:00
parent f3e5cd62b1
commit 2bcda34f6a
13 changed files with 225 additions and 37 deletions

View 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);

View 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);