46 lines
1.9 KiB
Python
46 lines
1.9 KiB
Python
"""Add SaaSRoleMapping
|
|
|
|
Revision ID: 9c4a95ac6726
|
|
Revises: 905726af73c8
|
|
Create Date: 2026-08-28 15:36:54.084287
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = '9c4a95ac6726'
|
|
down_revision: Union[str, None] = '905726af73c8'
|
|
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('saas_role_mappings',
|
|
sa.Column('id', sa.UUID(), nullable=False),
|
|
sa.Column('saas_role_id', sa.String(), nullable=False),
|
|
sa.Column('docqube_role_id', sa.UUID(), nullable=False),
|
|
sa.Column('metadata', sa.JSON(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=True),
|
|
sa.ForeignKeyConstraint(['docqube_role_id'], ['roles.id'], ondelete='CASCADE'),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_saas_role_mappings_id'), 'saas_role_mappings', ['id'], unique=False)
|
|
op.create_index(op.f('ix_saas_role_mappings_saas_role_id'), 'saas_role_mappings', ['saas_role_id'], unique=True)
|
|
op.execute("ALTER TABLE tenant_contacts DROP CONSTRAINT IF EXISTS uq_tenant_contacts_tenant_id_email")
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_unique_constraint('uq_tenant_contacts_tenant_id_email', 'tenant_contacts', ['tenant_id', 'email'])
|
|
op.drop_index(op.f('ix_saas_role_mappings_saas_role_id'), table_name='saas_role_mappings')
|
|
op.drop_index(op.f('ix_saas_role_mappings_id'), table_name='saas_role_mappings')
|
|
op.drop_table('saas_role_mappings')
|
|
# ### end Alembic commands ###
|