Skip to content

Commit

Permalink
first migration
Browse files Browse the repository at this point in the history
  • Loading branch information
HMnesterov committed Sep 10, 2023
1 parent f8f3e7e commit b73844f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions core/migrations/0001__init__ddl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
CREATE TABLE IF NOT EXISTS TGUser
(
id BIGINT PRIMARY KEY NOT NULL ,
hash VARCHAR(999) NOT NULL,
first_name VARCHAR(255) NULL,
username VARCHAR(255) NULL,
language_code VARCHAR(255) NULL,
is_bot BOOLEAN NOT NULL

);

CREATE TABLE IF NOT EXISTS TGChat
(
id BIGINT PRIMARY KEY NOT NULL ,
hash VARCHAR(999) NOT NULL,
full_name VARCHAR(255) NOT NULL ,
type VARCHAR(255) NULL

);

CREATE TABLE IF NOT EXISTS TGMessage
(
true_id UUID PRIMARY KEY NOT NULL ,
id BIGINT NOT NULL,
author_id BIGINT,
chat_id BIGINT,
text TEXT,
created_at TIMESTAMPTZ NOT NULL,
FOREIGN KEY (author_id) REFERENCES TGUser (id) ON DELETE CASCADE,
FOREIGN KEY (chat_id) REFERENCES TGChat (id) ON DELETE CASCADE
);

0 comments on commit b73844f

Please sign in to comment.