From dacdd3f0e2df652dff4c846854f5377f7d3fa866 Mon Sep 17 00:00:00 2001 From: Zyy Date: Thu, 15 Oct 2026 15:36:43 +0800 Subject: [PATCH] chore(db): consolidate unreleased proxy and privacy migration Keep published migrations unchanged and apply proxy enablement and privacy rule conversion in one migration. Co-authored-by: Codex --- .../gateway-store/tests/postgres/runtime_settings.rs | 11 +++-------- backend/migrations/.frozen-sha256 | 3 +-- backend/migrations/0031_outbound_proxy_enabled.sql | 2 -- ...vacy_rule_steps.sql => 0031_proxy_and_privacy.sql} | 3 +++ 4 files changed, 7 insertions(+), 12 deletions(-) delete mode 100644 backend/migrations/0031_outbound_proxy_enabled.sql rename backend/migrations/{0032_privacy_rule_steps.sql => 0031_proxy_and_privacy.sql} (88%) diff --git a/backend/crates/gateway-store/tests/postgres/runtime_settings.rs b/backend/crates/gateway-store/tests/postgres/runtime_settings.rs index f6af09461..934fd7698 100644 --- a/backend/crates/gateway-store/tests/postgres/runtime_settings.rs +++ b/backend/crates/gateway-store/tests/postgres/runtime_settings.rs @@ -225,13 +225,8 @@ async fn privacy_steps_migration_preserves_rules_and_other_settings() { serde_json::to_value(&loaded.values.codex_privacy_policy).unwrap(), expected ); - // 已迁移的规则再次执行转换也不产生写入或额外嵌套 - sqlx::raw_sql(include_str!( - "../../../../migrations/0032_privacy_rule_steps.sql" - )) - .execute(&database.pool) - .await - .unwrap(); + // 服务重启后再次检查迁移,不产生写入或额外嵌套 + super::TEST_MIGRATOR.run(&database.pool).await.unwrap(); let stored: serde_json::Value = sqlx::query_scalar("select to_jsonb(runtime_settings) from runtime_settings where id = 1") .fetch_one(&database.pool) @@ -271,7 +266,7 @@ async fn privacy_steps_migration_rejects_non_object_without_losing_data() { .unwrap(); assert_eq!(stored, invalid); let applied: bool = - sqlx::query_scalar("select exists(select 1 from _sqlx_migrations where version = 32)") + sqlx::query_scalar("select exists(select 1 from _sqlx_migrations where version = 31)") .fetch_one(&database.pool) .await .unwrap(); diff --git a/backend/migrations/.frozen-sha256 b/backend/migrations/.frozen-sha256 index f712b9043..4d69e34ad 100644 --- a/backend/migrations/.frozen-sha256 +++ b/backend/migrations/.frozen-sha256 @@ -28,5 +28,4 @@ d4b599066d7382a1c9cb6b3c003200046579e4fce3531f232cbd665a9d92c542 0026_codex_pri 31d6668707186d7c19cdd507e20162a08c7fbb8ba41ff4a4439d0a5e08369cad 0028_request_analytics.sql 1923f14095dac5f808a530db002c37e17168afa0778bc7f3da768c818133eec9 0029_usage_indexes_and_identity_snapshots.sql f10058e2b4c974b6d2ffa11be78b085504a233205253948c03357ef6fe234bca 0030_analytics_and_scheduling.sql -252ba957fa5c4f5171aee2aa238f2da7202a7c53dc6245ee4a210626089ec5a7 0031_outbound_proxy_enabled.sql -24b786f80a8bdebe3d915f60a9d68d5c7c9fc04fd4eaa9912f5d7a997fefa87f 0032_privacy_rule_steps.sql +b49832e205405de7ef078f3b65c0c19f2c030b8984d42411598738b6b6c146bf 0031_proxy_and_privacy.sql diff --git a/backend/migrations/0031_outbound_proxy_enabled.sql b/backend/migrations/0031_outbound_proxy_enabled.sql deleted file mode 100644 index d25b1aa17..000000000 --- a/backend/migrations/0031_outbound_proxy_enabled.sql +++ /dev/null @@ -1,2 +0,0 @@ --- 命名代理独立启停,保留连接配置和账号绑定 -alter table outbound_proxies add column enabled boolean not null default true; diff --git a/backend/migrations/0032_privacy_rule_steps.sql b/backend/migrations/0031_proxy_and_privacy.sql similarity index 88% rename from backend/migrations/0032_privacy_rule_steps.sql rename to backend/migrations/0031_proxy_and_privacy.sql index 5a180dde7..c1c3e11a6 100644 --- a/backend/migrations/0032_privacy_rule_steps.sql +++ b/backend/migrations/0031_proxy_and_privacy.sql @@ -1,3 +1,6 @@ +-- 命名代理独立启停,保留连接配置和账号绑定 +alter table outbound_proxies add column enabled boolean not null default true; + -- 非对象规则不能无损转换,拒绝升级以保留原始配置 do $$ begin