REFACTOR ALL APIs
This commit is contained in:
@@ -1,48 +0,0 @@
|
||||
"""add_demo_columns
|
||||
|
||||
Revision ID: 2a9b3c4d5e6f
|
||||
Revises: 1e8aebb4d9ce
|
||||
Create Date: 2025-10-02 17:00:00.000000+02:00
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '2a9b3c4d5e6f'
|
||||
down_revision: Union[str, None] = '1e8aebb4d9ce'
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
# Add demo-related columns to tenants table
|
||||
op.add_column('tenants', sa.Column('is_demo', sa.Boolean(), nullable=False, server_default='false'))
|
||||
op.add_column('tenants', sa.Column('is_demo_template', sa.Boolean(), nullable=False, server_default='false'))
|
||||
op.add_column('tenants', sa.Column('base_demo_tenant_id', sa.UUID(), nullable=True))
|
||||
op.add_column('tenants', sa.Column('demo_session_id', sa.String(length=100), nullable=True))
|
||||
op.add_column('tenants', sa.Column('demo_expires_at', sa.DateTime(timezone=True), nullable=True))
|
||||
|
||||
# Create indexes for demo columns
|
||||
op.create_index(op.f('ix_tenants_is_demo'), 'tenants', ['is_demo'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_is_demo_template'), 'tenants', ['is_demo_template'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_base_demo_tenant_id'), 'tenants', ['base_demo_tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_demo_session_id'), 'tenants', ['demo_session_id'], unique=False)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# Drop indexes
|
||||
op.drop_index(op.f('ix_tenants_demo_session_id'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_base_demo_tenant_id'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_is_demo_template'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_is_demo'), table_name='tenants')
|
||||
|
||||
# Drop columns
|
||||
op.drop_column('tenants', 'demo_expires_at')
|
||||
op.drop_column('tenants', 'demo_session_id')
|
||||
op.drop_column('tenants', 'base_demo_tenant_id')
|
||||
op.drop_column('tenants', 'is_demo_template')
|
||||
op.drop_column('tenants', 'is_demo')
|
||||
@@ -1,8 +1,8 @@
|
||||
"""initial_schema_20251001_1119
|
||||
"""initial_schema_20251006_1516
|
||||
|
||||
Revision ID: 1e8aebb4d9ce
|
||||
Revision ID: 964ef5a3ac09
|
||||
Revises:
|
||||
Create Date: 2025-10-01 11:19:18.038250+02:00
|
||||
Create Date: 2025-10-06 15:16:42.493219+02:00
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
@@ -12,7 +12,7 @@ import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = '1e8aebb4d9ce'
|
||||
revision: str = '964ef5a3ac09'
|
||||
down_revision: Union[str, None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
@@ -35,6 +35,11 @@ def upgrade() -> None:
|
||||
sa.Column('email', sa.String(length=255), nullable=True),
|
||||
sa.Column('is_active', sa.Boolean(), nullable=True),
|
||||
sa.Column('subscription_tier', sa.String(length=50), nullable=True),
|
||||
sa.Column('is_demo', sa.Boolean(), nullable=True),
|
||||
sa.Column('is_demo_template', sa.Boolean(), nullable=True),
|
||||
sa.Column('base_demo_tenant_id', sa.UUID(), nullable=True),
|
||||
sa.Column('demo_session_id', sa.String(length=100), nullable=True),
|
||||
sa.Column('demo_expires_at', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('ml_model_trained', sa.Boolean(), nullable=True),
|
||||
sa.Column('last_training_date', sa.DateTime(timezone=True), nullable=True),
|
||||
sa.Column('owner_id', sa.UUID(), nullable=False),
|
||||
@@ -43,6 +48,10 @@ def upgrade() -> None:
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('subdomain')
|
||||
)
|
||||
op.create_index(op.f('ix_tenants_base_demo_tenant_id'), 'tenants', ['base_demo_tenant_id'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_demo_session_id'), 'tenants', ['demo_session_id'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_is_demo'), 'tenants', ['is_demo'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_is_demo_template'), 'tenants', ['is_demo_template'], unique=False)
|
||||
op.create_index(op.f('ix_tenants_owner_id'), 'tenants', ['owner_id'], unique=False)
|
||||
op.create_table('subscriptions',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
@@ -86,5 +95,9 @@ def downgrade() -> None:
|
||||
op.drop_table('tenant_members')
|
||||
op.drop_table('subscriptions')
|
||||
op.drop_index(op.f('ix_tenants_owner_id'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_is_demo_template'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_is_demo'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_demo_session_id'), table_name='tenants')
|
||||
op.drop_index(op.f('ix_tenants_base_demo_tenant_id'), table_name='tenants')
|
||||
op.drop_table('tenants')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user