From d17f853a5f567f98ba07a952e557a23fddea79ab Mon Sep 17 00:00:00 2001 From: yangjianbo Date: Sun, 18 Jan 2026 11:45:43 +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=85=81=E8=AE=B8=E5=88=86=E7=BB=84=E5=88=97=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../006_add_users_allowed_groups_compat.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 backend/migrations/006_add_users_allowed_groups_compat.sql diff --git a/backend/migrations/006_add_users_allowed_groups_compat.sql b/backend/migrations/006_add_users_allowed_groups_compat.sql new file mode 100644 index 00000000..262945d4 --- /dev/null +++ b/backend/migrations/006_add_users_allowed_groups_compat.sql @@ -0,0 +1,15 @@ +-- 兼容旧库:若尚未创建 user_allowed_groups,则确保 users.allowed_groups 存在,避免 007 迁移回填失败。 +DO $$ +BEGIN + IF to_regclass('public.user_allowed_groups') IS NULL THEN + IF EXISTS ( + SELECT 1 + FROM information_schema.tables + WHERE table_schema = 'public' + AND table_name = 'users' + ) THEN + ALTER TABLE users + ADD COLUMN IF NOT EXISTS allowed_groups BIGINT[] DEFAULT NULL; + END IF; + END IF; +END $$;