| """add notifications table
|
|
|
| Revision ID: 3ee140dfb02a
|
| Revises: b5d1f9866721
|
| Create Date: 2026-01-15 11:08:50.265246
|
|
|
| """
|
| from typing import Sequence, Union
|
|
|
| from alembic import op
|
| import sqlalchemy as sa
|
|
|
|
|
|
|
| revision: str = '3ee140dfb02a'
|
| down_revision: Union[str, None] = 'b5d1f9866721'
|
| branch_labels: Union[str, Sequence[str], None] = None
|
| depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
| def upgrade() -> None:
|
| |
| op.create_table('notifications', |
| sa.Column('id', sa.Integer(), nullable=False), |
| sa.Column('user_id', sa.Integer(), nullable=False), |
| sa.Column('type', sa.String(length=50), nullable=False), |
| sa.Column('title', sa.String(length=255), nullable=False), |
| sa.Column('message', sa.Text(), nullable=False), |
| sa.Column('severity', sa.String(length=20), nullable=False), |
| sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True), |
| sa.Column('read', sa.Boolean(), nullable=True), |
| sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), |
| sa.PrimaryKeyConstraint('id') |
| ) |
| op.create_index(op.f('ix_notifications_created_at'), 'notifications', ['created_at'], unique=False) |
| op.create_index(op.f('ix_notifications_id'), 'notifications', ['id'], unique=False) |
| op.create_index(op.f('ix_notifications_read'), 'notifications', ['read'], unique=False) |
| op.create_index(op.f('ix_notifications_type'), 'notifications', ['type'], unique=False) |
| op.create_index(op.f('ix_notifications_user_id'), 'notifications', ['user_id'], unique=False) |
|
|
|
|
|
|
| def downgrade() -> None:
|
| |
| op.drop_index(op.f('ix_notifications_user_id'), table_name='notifications') |
| op.drop_index(op.f('ix_notifications_type'), table_name='notifications') |
| op.drop_index(op.f('ix_notifications_read'), table_name='notifications') |
| op.drop_index(op.f('ix_notifications_id'), table_name='notifications') |
| op.drop_index(op.f('ix_notifications_created_at'), table_name='notifications') |
| op.drop_table('notifications') |
|
|
|
|