Paijo commited on
update alembic/versions/3ee140dfb02a_add_notifications_table.py
Browse files
alembic/versions/3ee140dfb02a_add_notifications_table.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""add notifications table
|
| 2 |
+
|
| 3 |
+
Revision ID: 3ee140dfb02a
|
| 4 |
+
Revises: b5d1f9866721
|
| 5 |
+
Create Date: 2026-01-15 11:08:50.265246
|
| 6 |
+
|
| 7 |
+
"""
|
| 8 |
+
from typing import Sequence, Union
|
| 9 |
+
|
| 10 |
+
from alembic import op
|
| 11 |
+
import sqlalchemy as sa
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
# revision identifiers, used by Alembic.
|
| 15 |
+
revision: str = '3ee140dfb02a'
|
| 16 |
+
down_revision: Union[str, None] = 'b5d1f9866721'
|
| 17 |
+
branch_labels: Union[str, Sequence[str], None] = None
|
| 18 |
+
depends_on: Union[str, Sequence[str], None] = None
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def upgrade() -> None:
|
| 22 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 23 |
+
op.create_table('notifications',
|
| 24 |
+
sa.Column('id', sa.Integer(), nullable=False),
|
| 25 |
+
sa.Column('user_id', sa.Integer(), nullable=False),
|
| 26 |
+
sa.Column('type', sa.String(length=50), nullable=False),
|
| 27 |
+
sa.Column('title', sa.String(length=255), nullable=False),
|
| 28 |
+
sa.Column('message', sa.Text(), nullable=False),
|
| 29 |
+
sa.Column('severity', sa.String(length=20), nullable=False),
|
| 30 |
+
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
|
| 31 |
+
sa.Column('read', sa.Boolean(), nullable=True),
|
| 32 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
|
| 33 |
+
sa.PrimaryKeyConstraint('id')
|
| 34 |
+
)
|
| 35 |
+
op.create_index(op.f('ix_notifications_created_at'), 'notifications', ['created_at'], unique=False)
|
| 36 |
+
op.create_index(op.f('ix_notifications_id'), 'notifications', ['id'], unique=False)
|
| 37 |
+
op.create_index(op.f('ix_notifications_read'), 'notifications', ['read'], unique=False)
|
| 38 |
+
op.create_index(op.f('ix_notifications_type'), 'notifications', ['type'], unique=False)
|
| 39 |
+
op.create_index(op.f('ix_notifications_user_id'), 'notifications', ['user_id'], unique=False)
|
| 40 |
+
# ### end Alembic commands ###
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def downgrade() -> None:
|
| 44 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 45 |
+
op.drop_index(op.f('ix_notifications_user_id'), table_name='notifications')
|
| 46 |
+
op.drop_index(op.f('ix_notifications_type'), table_name='notifications')
|
| 47 |
+
op.drop_index(op.f('ix_notifications_read'), table_name='notifications')
|
| 48 |
+
op.drop_index(op.f('ix_notifications_id'), table_name='notifications')
|
| 49 |
+
op.drop_index(op.f('ix_notifications_created_at'), table_name='notifications')
|
| 50 |
+
op.drop_table('notifications')
|
| 51 |
+
# ### end Alembic commands ###
|