tg_rss_bot/migrations/0000.initial_schema.py
Miroslavsckaya 31c112a4fa
All checks were successful
continuous-integration/drone/push Build is passing
Database migration (#45)
Closes #16

Co-authored-by: mitsuha_s <stmiroslavsckaya@yandex.ru>
Reviewed-on: #45
Reviewed-by: Alexey Skobkin <skobkin-ru@ya.ru>
2022-08-21 23:43:35 +03:00

31 lines
705 B
Python

from yoyo import step
steps = [
step(
'CREATE TABLE users ('
' id SERIAL PRIMARY KEY,'
' telegram_id INTEGER NOT NULL UNIQUE'
')'
),
step(
'CREATE TABLE feeds ('
' id SERIAL PRIMARY KEY,'
' url TEXT NOT NULL UNIQUE'
')'
),
step(
'CREATE TABLE subscriptions ('
' user_id INTEGER REFERENCES users,'
' feed_id INTEGER REFERENCES feeds,'
' UNIQUE (user_id, feed_id)'
')'
),
step(
'CREATE TABLE feeds_last_items ('
' feed_id INTEGER REFERENCES feeds ON DELETE CASCADE,'
' url TEXT NOT NULL,'
' guid TEXT'
')'
)
]