|
|
|
|
@@ -0,0 +1,52 @@
|
|
|
|
|
"""v0.1.7 identity baseline
|
|
|
|
|
|
|
|
|
|
Revision ID: 5c6d7e8f9a10
|
|
|
|
|
Revises: None
|
|
|
|
|
Create Date: 2026-07-11 00:00:00.000000
|
|
|
|
|
"""
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
from alembic import op
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
revision = '5c6d7e8f9a10'
|
|
|
|
|
down_revision = None
|
|
|
|
|
branch_labels = None
|
|
|
|
|
depends_on = ('4f2a9c8e7b6d', '4a5b6c7d8e9f')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upgrade() -> None:
|
|
|
|
|
op.create_table('identity_identities',
|
|
|
|
|
sa.Column('id', sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column('display_name', sa.String(length=255), nullable=True),
|
|
|
|
|
sa.Column('external_subject', sa.String(length=255), nullable=True),
|
|
|
|
|
sa.Column('source', sa.String(length=50), nullable=False),
|
|
|
|
|
sa.Column('is_active', sa.Boolean(), nullable=False),
|
|
|
|
|
sa.Column('settings', sa.JSON(), nullable=False),
|
|
|
|
|
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
|
|
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
|
|
|
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_identity_identities'))
|
|
|
|
|
)
|
|
|
|
|
op.create_index(op.f('ix_identity_identities_external_subject'), 'identity_identities', ['external_subject'], unique=False)
|
|
|
|
|
op.create_table('identity_account_links',
|
|
|
|
|
sa.Column('id', sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column('identity_id', sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column('account_id', sa.String(length=36), nullable=False),
|
|
|
|
|
sa.Column('is_primary', sa.Boolean(), nullable=False),
|
|
|
|
|
sa.Column('source', sa.String(length=50), nullable=False),
|
|
|
|
|
sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
|
|
|
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False),
|
|
|
|
|
sa.ForeignKeyConstraint(['identity_id'], ['identity_identities.id'], name=op.f('fk_identity_account_links_identity_id_identity_identities'), ondelete='CASCADE'),
|
|
|
|
|
sa.PrimaryKeyConstraint('id', name=op.f('pk_identity_account_links')),
|
|
|
|
|
sa.UniqueConstraint('identity_id', 'account_id', name='uq_identity_module_account_links_identity_account')
|
|
|
|
|
)
|
|
|
|
|
op.create_index(op.f('ix_identity_account_links_account_id'), 'identity_account_links', ['account_id'], unique=False)
|
|
|
|
|
op.create_index(op.f('ix_identity_account_links_identity_id'), 'identity_account_links', ['identity_id'], unique=False)
|
|
|
|
|
op.create_index('uq_identity_module_account_links_primary_account', 'identity_account_links', ['account_id'], unique=True, sqlite_where=sa.text('is_primary = 1'), postgresql_where=sa.text('is_primary IS TRUE'))
|
|
|
|
|
op.create_index('uq_identity_module_account_links_primary_identity', 'identity_account_links', ['identity_id'], unique=True, sqlite_where=sa.text('is_primary = 1'), postgresql_where=sa.text('is_primary IS TRUE'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def downgrade() -> None:
|
|
|
|
|
op.drop_table('identity_account_links')
|
|
|
|
|
op.drop_table('identity_identities')
|