vegapokerbot/internal/db/migrations/1_init.up.sql

23 lines
555 B
SQL

CREATE TABLE "user" (
id BIGSERIAL PRIMARY KEY,
telegram_id BIGINT NOT NULL,
chat_id BIGINT NOT NULL,
language VARCHAR(8)
);
CREATE TABLE chat (
id BIGSERIAL PRIMARY KEY,
telegram_id BIGINT NOT NULL,
user_id BIGINT NOT NULL,
keyboard_type VARCHAR(6),
FOREIGN KEY (user_id) REFERENCES "user"(id) ON DELETE CASCADE
);
CREATE TABLE integration (
id BIGSERIAL PRIMARY KEY,
type VARCHAR(32) NOT NULL,
chat_id BIGINT NOT NULL,
params JSON,
FOREIGN KEY (chat_id) REFERENCES chat(id) ON DELETE CASCADE
);