2022-08-21 16:17:44 +00:00
|
|
|
from yoyo import step
|
|
|
|
|
|
|
|
steps = [
|
2022-08-21 20:03:43 +00:00
|
|
|
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'
|
|
|
|
')'
|
|
|
|
),
|
2022-08-21 16:17:44 +00:00
|
|
|
step(
|
2022-08-21 16:28:38 +00:00
|
|
|
'CREATE TABLE subscriptions ('
|
2022-08-21 16:17:44 +00:00
|
|
|
' user_id INTEGER REFERENCES users,'
|
|
|
|
' feed_id INTEGER REFERENCES feeds,'
|
|
|
|
' UNIQUE (user_id, feed_id)'
|
|
|
|
')'
|
|
|
|
),
|
|
|
|
step(
|
2022-08-21 16:28:38 +00:00
|
|
|
'CREATE TABLE feeds_last_items ('
|
2022-08-21 16:17:44 +00:00
|
|
|
' feed_id INTEGER REFERENCES feeds ON DELETE CASCADE,'
|
|
|
|
' url TEXT NOT NULL,'
|
|
|
|
' guid TEXT'
|
|
|
|
')'
|
|
|
|
)
|
|
|
|
]
|