added more pomidoro
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
from sqlalchemy import inspect, text
|
||||
|
||||
from app.db.base import engine
|
||||
|
||||
|
||||
def run_migrations() -> None:
|
||||
inspector = inspect(engine)
|
||||
|
||||
if "pomodoro_sessions" in inspector.get_table_names():
|
||||
columns = {col["name"] for col in inspector.get_columns("pomodoro_sessions")}
|
||||
with engine.begin() as conn:
|
||||
if "phase" not in columns:
|
||||
conn.execute(
|
||||
text("ALTER TABLE pomodoro_sessions ADD COLUMN phase VARCHAR(32) DEFAULT 'work'")
|
||||
)
|
||||
if "completion_notified" not in columns:
|
||||
conn.execute(
|
||||
text(
|
||||
"ALTER TABLE pomodoro_sessions "
|
||||
"ADD COLUMN completion_notified BOOLEAN DEFAULT 0"
|
||||
)
|
||||
)
|
||||
|
||||
if "pomodoro_cycles" not in inspector.get_table_names():
|
||||
return
|
||||
|
||||
columns = {col["name"] for col in inspector.get_columns("pomodoro_cycles")}
|
||||
with engine.begin() as conn:
|
||||
if "chat_notify_seq" not in columns:
|
||||
conn.execute(
|
||||
text("ALTER TABLE pomodoro_cycles ADD COLUMN chat_notify_seq INTEGER DEFAULT 0")
|
||||
)
|
||||
Reference in New Issue
Block a user