now on sql

This commit is contained in:
kr0sh512
2024-12-23 04:05:46 +03:00
parent 0e7c185517
commit 3b29315129
4 changed files with 232 additions and 223 deletions
+31
View File
@@ -0,0 +1,31 @@
CREATE type chat_type AS ENUM ('private', 'group', 'supergroup', 'channel');
CREATE TABLE users (
id BIGINT PRIMARY KEY,
username TEXT,
firstname TEXT,
lastname TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_message BIGINT NOT NULL DEFAULT 0,
remind_delta BIGINT NOT NULL DEFAULT 21600,
chat chat_type NOT NULL
);
CREATE Table lists (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users (id),
name TEXT NOT NULL,
discription TEXT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE notes (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users (id),
list_id BIGINT NOT NULL REFERENCES lists (id),
content TEXT NOT NULL,
remind_at TIMESTAMP,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);