From 8391d480c9f07155f2f8468172c6f0d2aa9caee5 Mon Sep 17 00:00:00 2001 From: yangjianbo Date: Sun, 18 Jan 2026 11:52:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=95=B0=E6=8D=AE=E5=BA=93):=20=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E5=88=86=E7=BB=84=E5=88=97=E5=9B=9E=E5=A1=AB=E5=89=8D?= =?UTF-8?q?=E7=BD=AE=E4=BF=9D=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../006b_guard_users_allowed_groups.sql | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 backend/migrations/006b_guard_users_allowed_groups.sql diff --git a/backend/migrations/006b_guard_users_allowed_groups.sql b/backend/migrations/006b_guard_users_allowed_groups.sql new file mode 100644 index 00000000..79771bf5 --- /dev/null +++ b/backend/migrations/006b_guard_users_allowed_groups.sql @@ -0,0 +1,27 @@ +-- 兼容缺失 users.allowed_groups 的老库,确保 007 回填可执行。 +DO $$ +BEGIN + IF EXISTS ( + SELECT 1 + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'users' + ) THEN + IF NOT EXISTS ( + SELECT 1 + FROM information_schema.columns + WHERE table_schema = 'public' + AND table_name = 'users' + AND column_name = 'allowed_groups' + ) THEN + IF NOT EXISTS ( + SELECT 1 + FROM schema_migrations + WHERE filename = '014_drop_legacy_allowed_groups.sql' + ) THEN + ALTER TABLE users + ADD COLUMN IF NOT EXISTS allowed_groups BIGINT[] DEFAULT NULL; + END IF; + END IF; + END IF; +END $$;