From 9f5fdfccec031ce91cde6f15f6bcf61522065dc2 Mon Sep 17 00:00:00 2001 From: Yansong Zhang <916125788@qq.com> Date: Thu, 3 Sep 2026 17:29:14 +0800 Subject: [PATCH] fix(migration): avoid backfilling Tokener billing profiles --- ...7b8c9_add_tenant_model_billing_profiles.py | 39 ------------------- 1 file changed, 39 deletions(-) diff --git a/api/migrations/versions/2026_09_03_1000-d4e5f6a7b8c9_add_tenant_model_billing_profiles.py b/api/migrations/versions/2026_09_03_1000-d4e5f6a7b8c9_add_tenant_model_billing_profiles.py index a1d18866bf9..aed30dca1dd 100644 --- a/api/migrations/versions/2026_09_03_1000-d4e5f6a7b8c9_add_tenant_model_billing_profiles.py +++ b/api/migrations/versions/2026_09_03_1000-d4e5f6a7b8c9_add_tenant_model_billing_profiles.py @@ -37,45 +37,6 @@ def upgrade(): ), sa.PrimaryKeyConstraint("tenant_id", name=op.f("tenant_model_billing_profile_pkey")), ) - bind = op.get_bind() - if bind.dialect.name == "postgresql": - op.execute( - sa.text( - """ - INSERT INTO tenant_model_billing_profiles (tenant_id, model_billing_source) - SELECT tenant_id, 'tokener' - FROM tenant_tokener_integrations - ON CONFLICT (tenant_id) DO UPDATE - SET model_billing_source = EXCLUDED.model_billing_source - """ - ) - ) - elif bind.dialect.name in {"mysql", "mariadb"}: - op.execute( - sa.text( - """ - INSERT INTO tenant_model_billing_profiles (tenant_id, model_billing_source) - SELECT tenant_id, 'tokener' - FROM tenant_tokener_integrations - ON DUPLICATE KEY UPDATE model_billing_source = VALUES(model_billing_source) - """ - ) - ) - else: - op.execute( - sa.text( - """ - INSERT INTO tenant_model_billing_profiles (tenant_id, model_billing_source) - SELECT integration.tenant_id, 'tokener' - FROM tenant_tokener_integrations AS integration - WHERE NOT EXISTS ( - SELECT 1 - FROM tenant_model_billing_profiles AS profile - WHERE profile.tenant_id = integration.tenant_id - ) - """ - ) - ) def downgrade():