mirror of
https://github.com/mblanke/ThreatHunt.git
synced 2026-03-01 14:00:20 -05:00
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
"""Add Phase 3 tables
|
|
|
|
Revision ID: b2c3d4e5f6g7
|
|
Revises: a1b2c3d4e5f6
|
|
Create Date: 2025-12-09 17:30:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = 'b2c3d4e5f6g7'
|
|
down_revision: Union[str, Sequence[str], None] = 'a1b2c3d4e5f6'
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
"""Upgrade schema for Phase 3."""
|
|
|
|
# Create notifications table
|
|
op.create_table(
|
|
'notifications',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('user_id', sa.Integer(), nullable=False),
|
|
sa.Column('tenant_id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(), nullable=False),
|
|
sa.Column('message', sa.Text(), nullable=False),
|
|
sa.Column('notification_type', sa.String(), nullable=False),
|
|
sa.Column('is_read', sa.Boolean(), nullable=False),
|
|
sa.Column('link', sa.String(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ),
|
|
sa.ForeignKeyConstraint(['user_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_created_at'), 'notifications', ['created_at'], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
"""Downgrade schema for Phase 3."""
|
|
|
|
# Drop notifications table
|
|
op.drop_index(op.f('ix_notifications_created_at'), table_name='notifications')
|
|
op.drop_index(op.f('ix_notifications_id'), table_name='notifications')
|
|
op.drop_table('notifications')
|