tg_rss_bot/migrations/0000.initial_schema.py

21 lines
657 B
Python
Raw Normal View History

2022-08-21 16:17:44 +00:00
from yoyo import step
steps = [
step('CREATE TABLE IF NOT EXISTS users (id SERIAL PRIMARY KEY, telegram_id INTEGER NOT NULL UNIQUE)'),
step('CREATE TABLE IF NOT EXISTS feeds (id SERIAL PRIMARY KEY, url TEXT NOT NULL UNIQUE)'),
step(
'CREATE TABLE IF NOT EXISTS subscriptions ('
' user_id INTEGER REFERENCES users,'
' feed_id INTEGER REFERENCES feeds,'
' UNIQUE (user_id, feed_id)'
')'
),
step(
'CREATE TABLE IF NOT EXISTS feeds_last_items ('
' feed_id INTEGER REFERENCES feeds ON DELETE CASCADE,'
' url TEXT NOT NULL,'
' guid TEXT'
')'
)
]