38 lines
986 B
Python
38 lines
986 B
Python
|
|
"""add target_mode to notifications
|
||
|
|
|
||
|
|
Revision ID: 20260416_0003
|
||
|
|
Revises: 20260416_0002
|
||
|
|
Create Date: 2026-04-16
|
||
|
|
"""
|
||
|
|
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
revision: str = "20260416_0003"
|
||
|
|
down_revision: Union[str, Sequence[str], None] = "20260416_0002"
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.add_column(
|
||
|
|
"notifications",
|
||
|
|
sa.Column(
|
||
|
|
"target_mode",
|
||
|
|
sa.String(32),
|
||
|
|
nullable=False,
|
||
|
|
server_default="all_users",
|
||
|
|
),
|
||
|
|
)
|
||
|
|
op.execute(
|
||
|
|
"ALTER TABLE notifications ADD CONSTRAINT ck_notifications_target_mode "
|
||
|
|
"CHECK (target_mode IN ('new_users', 'exist_users', 'all_users', 'user_ids'))"
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.execute("ALTER TABLE notifications DROP CONSTRAINT ck_notifications_target_mode")
|
||
|
|
op.drop_column("notifications", "target_mode")
|