"""notifications + notification_reads (platform notifications) Revision ID: 0010_notifications Revises: 0009_support_access Create Date: 2026-11-13 11:06:59.999254 """ from alembic import op import sqlalchemy as sa from core.timeutil import UTCDateTime revision = '0010_notifications' down_revision = '0009_support_access' branch_labels = None depends_on = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('notifications', sa.Column('id', sa.Integer(), autoincrement=True, nullable=False), sa.Column('key', sa.String(), nullable=False), sa.Column('severity', sa.String(), nullable=False), sa.Column('audience', sa.String(), nullable=False), sa.Column('params', sa.JSON(), nullable=True), sa.Column('dedupe_key', sa.String(), nullable=True), sa.Column('count', sa.Integer(), nullable=False), sa.Column('created_at', UTCDateTime(), nullable=False), sa.Column('last_at', UTCDateTime(), nullable=False), sa.Column('expires_at', UTCDateTime(), nullable=True), sa.PrimaryKeyConstraint('id'), sqlite_autoincrement=True ) with op.batch_alter_table('notifications', schema=None) as batch_op: batch_op.create_index(batch_op.f('ix_notifications_audience'), ['audience'], unique=False) batch_op.create_index(batch_op.f('ix_notifications_created_at'), ['created_at'], unique=False) batch_op.create_index(batch_op.f('ix_notifications_dedupe_key'), ['dedupe_key'], unique=False) batch_op.create_index(batch_op.f('ix_notifications_key'), ['key'], unique=False) op.create_table('notification_reads', sa.Column('notification_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('read_at', UTCDateTime(), nullable=False), sa.ForeignKeyConstraint(['notification_id'], ['notifications.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('notification_id', 'user_id') ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_table('notification_reads') with op.batch_alter_table('notifications', schema=None) as batch_op: batch_op.drop_index(batch_op.f('ix_notifications_key')) batch_op.drop_index(batch_op.f('ix_notifications_dedupe_key')) batch_op.drop_index(batch_op.f('ix_notifications_created_at')) batch_op.drop_index(batch_op.f('ix_notifications_audience')) op.drop_table('notifications') # ### end Alembic commands ###