30 lines
856 B
Python
30 lines
856 B
Python
"""Add entity_type and entity_id to notifications table.
|
|
|
|
Revision ID: 0063
|
|
Revises: 0062
|
|
Create Date: 2026-07-29
|
|
|
|
The notification model has entity_type and entity_id fields but the DB
|
|
table was never migrated. This causes INSERT failures.
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects.postgresql import UUID
|
|
|
|
revision = "0063"
|
|
down_revision = "0062"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.execute("ALTER TABLE notifications ADD COLUMN IF NOT EXISTS entity_type VARCHAR(50)")
|
|
op.execute("CREATE INDEX IF NOT EXISTS ix_notifications_entity_type ON notifications (entity_type)")
|
|
op.execute("ALTER TABLE notifications ADD COLUMN IF NOT EXISTS entity_id UUID")
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_column("notifications", "entity_id")
|
|
op.drop_column("notifications", "entity_type")
|