52 lines
2.1 KiB
Python
52 lines
2.1 KiB
Python
"""notification table
|
|
|
|
Revision ID: ac71b9a4b040
|
|
Revises: 0ce7107c1910
|
|
Create Date: 2025-05-14 16:14:23.750891
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'ac71b9a4b040'
|
|
down_revision: Union[str, None] = '0ce7107c1910'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('notifications',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(), nullable=True),
|
|
sa.Column('message', sa.String(), nullable=True),
|
|
sa.Column('is_read', sa.Boolean(), nullable=True),
|
|
sa.Column('sender_id', sa.Integer(), nullable=False),
|
|
sa.Column('receiver_id', sa.Integer(), nullable=False),
|
|
sa.Column('create_time', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
|
sa.Column('update_time', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
|
sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True),
|
|
sa.ForeignKeyConstraint(['receiver_id'], ['users.id'], ),
|
|
sa.ForeignKeyConstraint(['sender_id'], ['users.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_notifications_id'), 'notifications', ['id'], unique=False)
|
|
op.create_index(op.f('ix_notifications_receiver_id'), 'notifications', ['receiver_id'], unique=False)
|
|
op.create_index(op.f('ix_notifications_sender_id'), 'notifications', ['sender_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema."""
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_notifications_sender_id'), table_name='notifications')
|
|
op.drop_index(op.f('ix_notifications_receiver_id'), table_name='notifications')
|
|
op.drop_index(op.f('ix_notifications_id'), table_name='notifications')
|
|
op.drop_table('notifications')
|
|
# ### end Alembic commands ###
|