"""Migration PostgreSQL UUID

Revision ID: b706fae9ff58
Revises: 
Create Date: 2025-12-16 18:18:17.425853

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'b706fae9ff58'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('users',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('password', sa.String(length=200), nullable=False),
    sa.Column('company_name', sa.String(length=150), nullable=True),
    sa.Column('role', sa.String(length=20), nullable=False),
    sa.Column('is_active_account', sa.Boolean(), nullable=False),
    sa.Column('can_audit', sa.Boolean(), nullable=False),
    sa.Column('engagement_end_date', sa.DateTime(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=False),
    sa.Column('updated_at', sa.DateTime(), nullable=False),
    sa.Column('two_factor_secret', sa.String(length=32), nullable=True),
    sa.Column('two_factor_enabled', sa.Boolean(), nullable=False),
    sa.Column('manager_id', sa.String(length=36), nullable=True),
    sa.ForeignKeyConstraint(['manager_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_users_email'), ['email'], unique=True)
        batch_op.create_index(batch_op.f('ix_users_manager_id'), ['manager_id'], unique=False)
        batch_op.create_index(batch_op.f('ix_users_role'), ['role'], unique=False)

    op.create_table('rapports',
    sa.Column('id', sa.String(length=36), nullable=False),
    sa.Column('date_creation', sa.DateTime(), nullable=False),
    sa.Column('nom_client', sa.String(length=150), nullable=False),
    sa.Column('score_total', sa.Integer(), nullable=False),
    sa.Column('raw_data', sa.Text(), nullable=True),
    sa.Column('preconisations_json', sa.Text(), nullable=False),
    sa.Column('user_id', sa.String(length=36), nullable=False),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    with op.batch_alter_table('rapports', schema=None) as batch_op:
        batch_op.create_index(batch_op.f('ix_rapports_date_creation'), ['date_creation'], unique=False)
        batch_op.create_index(batch_op.f('ix_rapports_user_id'), ['user_id'], unique=False)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('rapports', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_rapports_user_id'))
        batch_op.drop_index(batch_op.f('ix_rapports_date_creation'))

    op.drop_table('rapports')
    with op.batch_alter_table('users', schema=None) as batch_op:
        batch_op.drop_index(batch_op.f('ix_users_role'))
        batch_op.drop_index(batch_op.f('ix_users_manager_id'))
        batch_op.drop_index(batch_op.f('ix_users_email'))

    op.drop_table('users')
    # ### end Alembic commands ###
