Maia/backend/alembic/versions/5965c1a94621_initial_schema.py

90 lines
4.1 KiB
Python

"""initial_schema
Revision ID: 5965c1a94621
Revises:
Create Date: 2026-04-13 20:25:03.459694
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = '5965c1a94621'
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('users',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('email', sa.String(), nullable=False),
sa.Column('password_hash', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False)
op.create_table('meetings',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('title', sa.String(), nullable=True),
sa.Column('date', sa.DateTime(), nullable=False),
sa.Column('duration', sa.Integer(), nullable=True),
sa.Column('audio_path', sa.String(), nullable=True),
sa.Column('status', sa.Enum('uploading', 'processing', 'transcribing', 'analyzing', 'completed', 'error', name='meetingstatus'), nullable=False),
sa.Column('transcription', sa.JSON(), nullable=True),
sa.Column('user_id', sa.UUID(), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_meetings_id'), 'meetings', ['id'], unique=False)
op.create_index(op.f('ix_meetings_user_id'), 'meetings', ['user_id'], unique=False)
op.create_table('analyses',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('meeting_id', sa.UUID(), nullable=False),
sa.Column('type', sa.Enum('minutes', 'sentiment', 'psychological', 'communication', 'summary', name='analysistype'), nullable=False),
sa.Column('content', sa.JSON(), nullable=False),
sa.Column('model_used', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['meeting_id'], ['meetings.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_analyses_id'), 'analyses', ['id'], unique=False)
op.create_index(op.f('ix_analyses_meeting_id'), 'analyses', ['meeting_id'], unique=False)
op.create_table('meeting_participants',
sa.Column('id', sa.UUID(), nullable=False),
sa.Column('meeting_id', sa.UUID(), nullable=False),
sa.Column('speaker_label', sa.String(), nullable=False),
sa.Column('voice_profile_id', sa.UUID(), nullable=True),
sa.Column('identified_name', sa.String(), nullable=True),
sa.Column('confidence_score', sa.Float(), nullable=True),
sa.Column('talk_time_seconds', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['meeting_id'], ['meetings.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_meeting_participants_id'), 'meeting_participants', ['id'], unique=False)
op.create_index(op.f('ix_meeting_participants_meeting_id'), 'meeting_participants', ['meeting_id'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_meeting_participants_meeting_id'), table_name='meeting_participants')
op.drop_index(op.f('ix_meeting_participants_id'), table_name='meeting_participants')
op.drop_table('meeting_participants')
op.drop_index(op.f('ix_analyses_meeting_id'), table_name='analyses')
op.drop_index(op.f('ix_analyses_id'), table_name='analyses')
op.drop_table('analyses')
op.drop_index(op.f('ix_meetings_user_id'), table_name='meetings')
op.drop_index(op.f('ix_meetings_id'), table_name='meetings')
op.drop_table('meetings')
op.drop_index(op.f('ix_users_id'), table_name='users')
op.drop_index(op.f('ix_users_email'), table_name='users')
op.drop_table('users')
# ### end Alembic commands ###