"""initial schema Revision ID: fbd00c295888 Revises: Create Date: 2026-09-26 19:45:54.541490 """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa revision: str = 'fbd00c295888' down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('broadcast_templates', sa.Column('id', sa.Integer(), nullable=False), sa.Column('code', sa.String(length=64), nullable=False), sa.Column('name', sa.String(length=200), nullable=False), sa.Column('type', sa.Enum('info', 'education', 'rating', name='broadcasttype', native_enum=False, length=20), nullable=False), sa.Column('body_template', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_table('federal_districts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=100), nullable=False), sa.Column('code', sa.String(length=20), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code'), sa.UniqueConstraint('name') ) op.create_table('goals', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=200), nullable=False), sa.Column('description', sa.String(length=1000), nullable=True), sa.Column('target_value', sa.Numeric(precision=14, scale=2), nullable=True), sa.Column('unit', sa.String(length=32), nullable=True), sa.Column('is_active', sa.Boolean(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.PrimaryKeyConstraint('id') ) op.create_table('knowledge_categories', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=200), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('code', sa.Enum('admin', 'coordinator', 'region_head', 'member', 'deputy', name='rolecode', native_enum=False, length=20), nullable=False), sa.Column('name', sa.String(length=100), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('code') ) op.create_table('users', sa.Column('id', sa.Integer(), nullable=False), sa.Column('full_name', sa.String(length=200), nullable=True), sa.Column('messenger_type', sa.Enum('telegram', 'max', name='messengertype', native_enum=False, length=20), nullable=False), sa.Column('messenger_id', sa.String(length=64), nullable=False), sa.Column('phone', sa.String(length=32), nullable=True), sa.Column('status', sa.Enum('active', 'blocked', 'pending', name='userstatus', native_enum=False, length=20), nullable=False), sa.Column('member_type', sa.Enum('member', 'resident', name='membertype', native_enum=False, length=20), nullable=True), sa.Column('joined_at', sa.Date(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('messenger_type', 'messenger_id', name='uq_user_messenger') ) op.create_table('assistant_actions', sa.Column('id', sa.Integer(), nullable=False), sa.Column('owner_user_id', sa.Integer(), nullable=False), sa.Column('action', sa.String(length=100), nullable=False), sa.Column('entity_type', sa.String(length=100), nullable=True), sa.Column('entity_id', sa.String(length=100), nullable=True), sa.Column('payload', sa.JSON(), nullable=True), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['owner_user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('assistant_configs', sa.Column('id', sa.Integer(), nullable=False), sa.Column('owner_user_id', sa.Integer(), nullable=False), sa.Column('enabled', sa.Boolean(), nullable=False), sa.Column('permissions', sa.JSON(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['owner_user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('owner_user_id') ) op.create_table('audit_log', sa.Column('id', sa.Integer(), nullable=False), sa.Column('actor_user_id', sa.Integer(), nullable=True), sa.Column('actor_type', sa.Enum('user', 'assistant', 'system', name='actortype', native_enum=False, length=20), nullable=False), sa.Column('action', sa.String(length=100), nullable=False), sa.Column('entity_type', sa.String(length=100), nullable=True), sa.Column('entity_id', sa.String(length=100), nullable=True), sa.Column('payload', sa.JSON(), nullable=True), sa.Column('ip', sa.String(length=64), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['actor_user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('broadcasts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('template_id', sa.Integer(), nullable=True), sa.Column('type', sa.Enum('info', 'education', 'rating', name='broadcasttype', native_enum=False, length=20), nullable=False), sa.Column('subject', sa.String(length=300), nullable=True), sa.Column('body', sa.Text(), nullable=True), sa.Column('audience_filter', sa.JSON(), nullable=True), sa.Column('status', sa.Enum('draft', 'scheduled', 'sending', 'sent', 'failed', name='broadcaststatus', native_enum=False, length=20), nullable=False), sa.Column('scheduled_at', sa.DateTime(timezone=True), nullable=True), sa.Column('started_at', sa.DateTime(timezone=True), nullable=True), sa.Column('finished_at', sa.DateTime(timezone=True), nullable=True), sa.Column('created_by', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.ForeignKeyConstraint(['template_id'], ['broadcast_templates.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('data_uploads', sa.Column('id', sa.Integer(), nullable=False), sa.Column('goal_id', sa.Integer(), nullable=False), sa.Column('file_key', sa.String(length=500), nullable=False), sa.Column('uploaded_by', sa.Integer(), nullable=True), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('processed_at', sa.DateTime(timezone=True), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ), sa.ForeignKeyConstraint(['uploaded_by'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('events', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=300), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('starts_at', sa.DateTime(timezone=True), nullable=False), sa.Column('ends_at', sa.DateTime(timezone=True), nullable=True), sa.Column('location', sa.String(length=300), nullable=True), sa.Column('created_by', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('knowledge_articles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=300), nullable=False), sa.Column('body', sa.Text(), nullable=False), sa.Column('category_id', sa.Integer(), nullable=True), sa.Column('created_by', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['category_id'], ['knowledge_categories.id'], ), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('platform_history', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=300), nullable=False), sa.Column('body', sa.Text(), nullable=True), sa.Column('event_date', sa.Date(), nullable=True), sa.Column('is_public', sa.Boolean(), nullable=False), sa.Column('created_by', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('regions', sa.Column('id', sa.Integer(), nullable=False), sa.Column('name', sa.String(length=200), nullable=False), sa.Column('federal_district_id', sa.Integer(), nullable=False), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['federal_district_id'], ['federal_districts.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('name') ) op.create_table('sessions', sa.Column('id', sa.String(length=36), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('token_hash', sa.String(length=128), nullable=False), sa.Column('messenger_type', sa.Enum('telegram', 'max', name='messengertype', native_enum=False, length=20), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False), sa.Column('revoked_at', sa.DateTime(timezone=True), nullable=True), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('token_hash') ) op.create_table('snapshots', sa.Column('id', sa.Integer(), nullable=False), sa.Column('goal_id', sa.Integer(), nullable=False), sa.Column('snapshot_date', sa.Date(), nullable=False), sa.Column('kind', sa.Enum('point0', 'current', 'history', name='snapshotkind', native_enum=False, length=20), nullable=False), sa.Column('source', sa.String(length=32), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('advices', sa.Column('id', sa.Integer(), nullable=False), sa.Column('region_id', sa.Integer(), nullable=False), sa.Column('goal_id', sa.Integer(), nullable=True), sa.Column('author_user_id', sa.Integer(), nullable=True), sa.Column('body', sa.Text(), nullable=False), sa.Column('status', sa.String(length=20), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['author_user_id'], ['users.id'], ), sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('broadcast_recipients', sa.Column('id', sa.Integer(), nullable=False), sa.Column('broadcast_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('status', sa.Enum('pending', 'sent', 'failed', name='recipientstatus', native_enum=False, length=20), nullable=False), sa.Column('sent_at', sa.DateTime(timezone=True), nullable=True), sa.Column('error', sa.Text(), nullable=True), sa.ForeignKeyConstraint(['broadcast_id'], ['broadcasts.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('broadcast_id', 'user_id', name='uq_broadcast_user') ) op.create_table('event_reminders', sa.Column('id', sa.Integer(), nullable=False), sa.Column('event_id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('remind_at', sa.DateTime(timezone=True), nullable=False), sa.Column('sent_at', sa.DateTime(timezone=True), nullable=True), sa.ForeignKeyConstraint(['event_id'], ['events.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('login_tokens', sa.Column('id', sa.String(length=36), nullable=False), sa.Column('token', sa.String(length=128), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('region_id', sa.Integer(), nullable=True), sa.Column('issued_by', sa.Integer(), nullable=True), sa.Column('status', sa.Enum('active', 'used', 'expired', 'revoked', name='logintokenstatus', native_enum=False, length=20), nullable=False), sa.Column('expires_at', sa.DateTime(timezone=True), nullable=False), sa.Column('used_at', sa.DateTime(timezone=True), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['issued_by'], ['users.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('token') ) op.create_table('region_card_history', sa.Column('id', sa.Integer(), nullable=False), sa.Column('region_id', sa.Integer(), nullable=False), sa.Column('field', sa.String(length=100), nullable=False), sa.Column('old_value', sa.String(length=1000), nullable=True), sa.Column('new_value', sa.String(length=1000), nullable=True), sa.Column('changed_by', sa.Integer(), nullable=True), sa.Column('changed_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['changed_by'], ['users.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('region_cards', sa.Column('region_id', sa.Integer(), nullable=False), sa.Column('population', sa.Integer(), nullable=True), sa.Column('head_user_id', sa.Integer(), nullable=True), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['head_user_id'], ['users.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('region_id') ) op.create_table('region_goal_values', sa.Column('id', sa.Integer(), nullable=False), sa.Column('snapshot_id', sa.Integer(), nullable=False), sa.Column('region_id', sa.Integer(), nullable=False), sa.Column('value', sa.Numeric(precision=14, scale=2), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['snapshot_id'], ['snapshots.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('snapshot_id', 'region_id', name='uq_snapshot_region') ) op.create_table('region_links', sa.Column('id', sa.Integer(), nullable=False), sa.Column('region_id', sa.Integer(), nullable=False), sa.Column('type', sa.Enum('community', 'chat', name='linktype', native_enum=False, length=20), nullable=False), sa.Column('title', sa.String(length=200), nullable=True), sa.Column('url', sa.String(length=500), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('requests', sa.Column('id', sa.Integer(), nullable=False), sa.Column('type', sa.Enum('join', 'access', 'event', 'support', name='requesttype', native_enum=False, length=20), nullable=False), sa.Column('user_id', sa.Integer(), nullable=True), sa.Column('region_id', sa.Integer(), nullable=True), sa.Column('subject', sa.String(length=300), nullable=True), sa.Column('body', sa.Text(), nullable=True), sa.Column('status', sa.Enum('new', 'in_progress', 'closed', name='requeststatus', native_enum=False, length=20), nullable=False), sa.Column('assigned_to', sa.Integer(), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['assigned_to'], ['users.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('tasks', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=300), nullable=False), sa.Column('description', sa.Text(), nullable=True), sa.Column('due_date', sa.Date(), nullable=True), sa.Column('priority', sa.Enum('low', 'medium', 'high', name='taskpriority', native_enum=False, length=20), nullable=False), sa.Column('status', sa.Enum('new', 'in_progress', 'review', 'done', name='taskstatus', native_enum=False, length=20), nullable=False), sa.Column('region_id', sa.Integer(), nullable=True), sa.Column('assignee_user_id', sa.Integer(), nullable=True), sa.Column('assignee_role', sa.Enum('admin', 'coordinator', 'region_head', 'member', 'deputy', name='rolecode', native_enum=False, length=20), nullable=True), sa.Column('created_by', sa.Integer(), nullable=True), sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['assignee_user_id'], ['users.id'], ), sa.ForeignKeyConstraint(['created_by'], ['users.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('user_regions', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('region_id', sa.Integer(), nullable=False), sa.Column('is_primary', sa.Boolean(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ondelete='CASCADE'), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id', 'region_id', name='uq_user_region') ) op.create_table('user_roles', sa.Column('id', sa.Integer(), nullable=False), sa.Column('user_id', sa.Integer(), nullable=False), sa.Column('role_id', sa.Integer(), nullable=False), sa.Column('region_id', sa.Integer(), nullable=True), sa.Column('granted_by', sa.Integer(), nullable=True), sa.Column('granted_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['granted_by'], ['users.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ), sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ), sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('user_id', 'role_id', 'region_id', name='uq_user_role') ) op.create_table('artifacts', sa.Column('id', sa.Integer(), nullable=False), sa.Column('title', sa.String(length=300), nullable=True), sa.Column('file_key', sa.String(length=500), nullable=False), sa.Column('file_name', sa.String(length=300), nullable=False), sa.Column('mime_type', sa.String(length=100), nullable=True), sa.Column('size_bytes', sa.BigInteger(), nullable=True), sa.Column('region_id', sa.Integer(), nullable=True), sa.Column('goal_id', sa.Integer(), nullable=True), sa.Column('task_id', sa.Integer(), nullable=True), sa.Column('uploaded_by', sa.Integer(), nullable=True), sa.Column('deleted_at', sa.DateTime(timezone=True), nullable=True), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['goal_id'], ['goals.id'], ), sa.ForeignKeyConstraint(['region_id'], ['regions.id'], ), sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), sa.ForeignKeyConstraint(['uploaded_by'], ['users.id'], ), sa.PrimaryKeyConstraint('id') ) op.create_table('request_comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('request_id', sa.Integer(), nullable=False), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('body', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['request_id'], ['requests.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_table('task_comments', sa.Column('id', sa.Integer(), nullable=False), sa.Column('task_id', sa.Integer(), nullable=False), sa.Column('author_id', sa.Integer(), nullable=True), sa.Column('body', sa.Text(), nullable=False), sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False), sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.drop_table('task_comments') op.drop_table('request_comments') op.drop_table('artifacts') op.drop_table('user_roles') op.drop_table('user_regions') op.drop_table('tasks') op.drop_table('requests') op.drop_table('region_links') op.drop_table('region_goal_values') op.drop_table('region_cards') op.drop_table('region_card_history') op.drop_table('login_tokens') op.drop_table('event_reminders') op.drop_table('broadcast_recipients') op.drop_table('advices') op.drop_table('snapshots') op.drop_table('sessions') op.drop_table('regions') op.drop_table('platform_history') op.drop_table('knowledge_articles') op.drop_table('events') op.drop_table('data_uploads') op.drop_table('broadcasts') op.drop_table('audit_log') op.drop_table('assistant_configs') op.drop_table('assistant_actions') op.drop_table('users') op.drop_table('roles') op.drop_table('knowledge_categories') op.drop_table('goals') op.drop_table('federal_districts') op.drop_table('broadcast_templates') # ### end Alembic commands ###