feat(phase-18): add in-app notification system (T-128, T-129)

This commit is contained in:
2026-02-09 13:52:04 +01:00
parent cda59de426
commit fb7f340038
16 changed files with 7577 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
"""add_notifications_table
Revision ID: b006notifications
Revises: b005v2indexes
Create Date: 2026-02-09 11:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID
# revision identifiers, used by Alembic.
revision: str = 'b006notifications'
down_revision: Union[str, Sequence[str], None] = 'b005v2indexes'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Create notifications table."""
op.create_table(
'notifications',
sa.Column('id', UUID(as_uuid=True), primary_key=True, server_default=sa.text('gen_random_uuid()')),
sa.Column('user_id', UUID(as_uuid=True), sa.ForeignKey('users.id'), nullable=False),
sa.Column('type', sa.String(), nullable=False),
sa.Column('title', sa.String(), nullable=False),
sa.Column('message', sa.Text(), nullable=True),
sa.Column('entity_type', sa.String(), nullable=True),
sa.Column('entity_id', UUID(as_uuid=True), nullable=True),
sa.Column('read', sa.Boolean(), server_default='false'),
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
)
op.create_index('ix_notifications_user_id', 'notifications', ['user_id'])
op.create_index('ix_notifications_read', 'notifications', ['read'])
op.create_index('ix_notifications_created_at', 'notifications', ['created_at'])
def downgrade() -> None:
"""Drop notifications table."""
op.drop_index('ix_notifications_created_at', table_name='notifications')
op.drop_index('ix_notifications_read', table_name='notifications')
op.drop_index('ix_notifications_user_id', table_name='notifications')
op.drop_table('notifications')