latest code
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
"""add signature config tables
|
||||
|
||||
Revision ID: af57c3d9f1c2
|
||||
Revises: daf45366d608
|
||||
Create Date: 2026-07-20 18:53:11.916379
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
import uuid
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'af57c3d9f1c2'
|
||||
down_revision: Union[str, None] = 'daf45366d608'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
op.create_table(
|
||||
'global_signature_configs',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), primary_key=True),
|
||||
sa.Column('active_provider', sa.String(length=50), nullable=False, server_default='zoho_sign'),
|
||||
sa.Column('docuseal_credentials', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('zoho_credentials', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('created_by_id', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by_id', sa.Integer(), nullable=True),
|
||||
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(['created_by_id'], ['users.id'], ondelete='SET NULL'),
|
||||
sa.ForeignKeyConstraint(['updated_by_id'], ['users.id'], ondelete='SET NULL')
|
||||
)
|
||||
|
||||
op.execute(
|
||||
"INSERT INTO global_signature_configs (id, active_provider, created_at, updated_at) "
|
||||
"VALUES (gen_random_uuid(), 'zoho_sign', now(), now())"
|
||||
)
|
||||
|
||||
op.create_table(
|
||||
'tenant_signature_configs',
|
||||
sa.Column('id', postgresql.UUID(as_uuid=True), primary_key=True),
|
||||
sa.Column('tenant_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('use_custom_credentials', sa.Boolean(), nullable=False, server_default='false'),
|
||||
sa.Column('custom_provider', sa.String(length=50), nullable=False, server_default='docuseal'),
|
||||
sa.Column('custom_credentials_json', postgresql.JSON(astext_type=sa.Text()), nullable=True),
|
||||
sa.Column('created_by_id', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_by_id', sa.Integer(), nullable=True),
|
||||
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(['created_by_id'], ['users.id'], ondelete='SET NULL'),
|
||||
sa.ForeignKeyConstraint(['tenant_id'], ['tenants.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['updated_by_id'], ['users.id'], ondelete='SET NULL')
|
||||
)
|
||||
op.create_index(op.f('ix_tenant_signature_configs_tenant_id'), 'tenant_signature_configs', ['tenant_id'], unique=True)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
op.drop_index(op.f('ix_tenant_signature_configs_tenant_id'), table_name='tenant_signature_configs')
|
||||
op.drop_table('tenant_signature_configs')
|
||||
op.drop_table('global_signature_configs')
|
||||
Reference in New Issue
Block a user