41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
"""create notifications
|
|
|
|
Revision ID: e2b6d8f0a4c1
|
|
Revises: c9e5a1b7d3f2
|
|
Create Date: 2026-11-01 18:55:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "e2b6d8f0a4c1"
|
|
down_revision: Union[str, Sequence[str], None] = "c9e5a1b7d3f2"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"notification",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("user_id", sa.Integer(), nullable=False),
|
|
sa.Column("message", sa.String(length=500), nullable=False),
|
|
sa.Column("is_read", sa.Boolean(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
sa.Column("read_at", sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(["user_id"], ["user.id"]),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(
|
|
op.f("ix_notification_user_id"), "notification", ["user_id"], unique=False
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index(op.f("ix_notification_user_id"), table_name="notification")
|
|
op.drop_table("notification")
|