"""TenantConsent model creation

Revision ID: 411f5593460e
Revises: 057fb975f0e3
Create Date: 2025-10-09 07:32:04.598209

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '411f5593460e'
down_revision = '057fb975f0e3'
branch_labels = None
depends_on = None


def upgrade():
    op.create_table('tenant_consent',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('tenant_id', sa.Integer(), nullable=False),
    sa.Column('partner_id', sa.Integer(), nullable=False),
    sa.Column('partner_service_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('consent_type', sa.String(length=50), nullable=False),
    sa.Column('consent_date', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('consent_dpa_version', sa.String(length=20), nullable=False),
    sa.Column('consent_t_c_version', sa.String(length=20), nullable=False),
    sa.Column('consent_data', sa.JSON(), nullable=False),
    sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('created_by', sa.Integer(), nullable=True),
    sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
    sa.Column('updated_by', sa.Integer(), nullable=True),
    sa.ForeignKeyConstraint(['created_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['partner_id'], ['public.partner.id'], ),
    sa.ForeignKeyConstraint(['partner_service_id'], ['public.partner_service.id'], ),
    sa.ForeignKeyConstraint(['tenant_id'], ['public.tenant.id'], ),
    sa.ForeignKeyConstraint(['updated_by'], ['public.user.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['public.user.id'], ),
    sa.PrimaryKeyConstraint('id'),
    schema='public'
    )

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('tenant_consent', schema='public')
    # ### end Alembic commands ###
