41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
"""add_app_settings_table
|
|
|
|
Revision ID: e76_app_settings
|
|
Revises: c1a2b3d4e5f6
|
|
Create Date: 2026-03-27 16:10:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects import postgresql
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'e76_app_settings'
|
|
down_revision = 'd4e5f6a7b8c9'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
def upgrade():
|
|
# Create a76.app_settings table
|
|
op.create_table(
|
|
'app_settings',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('tenant_id', sa.Integer(), nullable=True),
|
|
sa.Column('company_id', sa.Integer(), nullable=True),
|
|
sa.Column('settings', postgresql.JSONB(astext_type=sa.Text()), nullable=False, server_default='{}'),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
|
|
sa.ForeignKeyConstraint(['company_id'], ['a76.company.id'], ),
|
|
sa.ForeignKeyConstraint(['tenant_id'], ['core.tenants.id'], ),
|
|
sa.PrimaryKeyConstraint('id'),
|
|
sa.UniqueConstraint('tenant_id', 'company_id', name='uq_app_settings_tenant_company'),
|
|
schema='a76'
|
|
)
|
|
op.create_index(op.f('ix_a76_app_settings_company_id'), 'app_settings', ['company_id'], unique=False, schema='a76')
|
|
op.create_index(op.f('ix_a76_app_settings_tenant_id'), 'app_settings', ['tenant_id'], unique=False, schema='a76')
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_a76_app_settings_tenant_id'), table_name='app_settings', schema='a76')
|
|
op.drop_index(op.f('ix_a76_app_settings_company_id'), table_name='app_settings', schema='a76')
|
|
op.drop_table('app_settings', schema='a76')
|