FastAPI + SQLAlchemy/Alembic + MariaDB backend with Jinja2/htmx/Alpine server-rendered frontend. Multi-user via Google OAuth, daily habit tracking, monthly/weekly history views, Web Push reminders via APScheduler, and PWA support (manifest, service worker, offline caching). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
"""add user_id to habit and push_subscription
|
|
|
|
Revision ID: 0004_add_user_id_columns
|
|
Revises: 0003_add_user_table
|
|
Create Date: 2026-07-15
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0004_add_user_id_columns"
|
|
down_revision: Union[str, None] = "0003_add_user_table"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.add_column("habit", sa.Column("user_id", sa.Integer(), nullable=True))
|
|
op.create_foreign_key(
|
|
"fk_habit_user_id", "habit", "user", ["user_id"], ["id"], ondelete="CASCADE"
|
|
)
|
|
|
|
op.add_column("push_subscription", sa.Column("user_id", sa.Integer(), nullable=True))
|
|
op.create_foreign_key(
|
|
"fk_push_subscription_user_id",
|
|
"push_subscription",
|
|
"user",
|
|
["user_id"],
|
|
["id"],
|
|
ondelete="CASCADE",
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_constraint("fk_push_subscription_user_id", "push_subscription", type_="foreignkey")
|
|
op.drop_column("push_subscription", "user_id")
|
|
|
|
op.drop_constraint("fk_habit_user_id", "habit", type_="foreignkey")
|
|
op.drop_column("habit", "user_id")
|