From 721d82b91a19832246c3e6c96b81a288b53e7af5 Mon Sep 17 00:00:00 2001 From: Harry Date: Fri, 16 Jan 2026 19:02:03 +0800 Subject: [PATCH] refactor(sandbox): modify sandbox provider configuration by adding 'configure_type' column and updating unique constraints --- ...e916693_sandbox_provider_configure_type.py | 35 +------------------ 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/api/migrations/versions/2026_01_16_1728-45471e916693_sandbox_provider_configure_type.py b/api/migrations/versions/2026_01_16_1728-45471e916693_sandbox_provider_configure_type.py index 8b89c0d496..13ef816e4c 100644 --- a/api/migrations/versions/2026_01_16_1728-45471e916693_sandbox_provider_configure_type.py +++ b/api/migrations/versions/2026_01_16_1728-45471e916693_sandbox_provider_configure_type.py @@ -18,51 +18,18 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('tenant_credit_pools', - sa.Column('id', models.types.StringUUID(), server_default=sa.text('uuid_generate_v4()'), nullable=False), - sa.Column('tenant_id', models.types.StringUUID(), nullable=False), - sa.Column('pool_type', sa.String(length=40), server_default='trial', nullable=False), - sa.Column('quota_limit', sa.BigInteger(), nullable=False), - sa.Column('quota_used', sa.BigInteger(), nullable=False), - sa.Column('created_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), - sa.Column('updated_at', sa.DateTime(), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=False), - sa.PrimaryKeyConstraint('id', name='tenant_credit_pool_pkey') - ) - with op.batch_alter_table('tenant_credit_pools', schema=None) as batch_op: - batch_op.create_index('tenant_credit_pool_pool_type_idx', ['pool_type'], unique=False) - batch_op.create_index('tenant_credit_pool_tenant_id_idx', ['tenant_id'], unique=False) - - with op.batch_alter_table('messages', schema=None) as batch_op: - batch_op.create_index('message_created_at_id_idx', ['created_at', 'id'], unique=False) - + with op.batch_alter_table('sandbox_providers', schema=None) as batch_op: batch_op.add_column(sa.Column('configure_type', sa.String(length=20), server_default='user', nullable=False)) batch_op.drop_constraint(batch_op.f('unique_sandbox_provider_tenant_type'), type_='unique') batch_op.create_unique_constraint('unique_sandbox_provider_tenant_type', ['tenant_id', 'provider_type', 'configure_type']) - with op.batch_alter_table('workflow_runs', schema=None) as batch_op: - batch_op.create_index('workflow_run_created_at_id_idx', ['created_at', 'id'], unique=False) - # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('workflow_runs', schema=None) as batch_op: - batch_op.drop_index('workflow_run_created_at_id_idx') - with op.batch_alter_table('sandbox_providers', schema=None) as batch_op: batch_op.drop_constraint('unique_sandbox_provider_tenant_type', type_='unique') batch_op.create_unique_constraint(batch_op.f('unique_sandbox_provider_tenant_type'), ['tenant_id', 'provider_type'], postgresql_nulls_not_distinct=False) batch_op.drop_column('configure_type') - with op.batch_alter_table('messages', schema=None) as batch_op: - batch_op.drop_index('message_created_at_id_idx') - - with op.batch_alter_table('tenant_credit_pools', schema=None) as batch_op: - batch_op.drop_index('tenant_credit_pool_tenant_id_idx') - batch_op.drop_index('tenant_credit_pool_pool_type_idx') - - op.drop_table('tenant_credit_pools') - # ### end Alembic commands ###