Files
AIclinicalresearch/backend/prisma/migrations/20260315_journal_config_center_mvp/migration.sql
HaHafeng 83e395824b feat(rvw): complete journal config center MVP and tenant login routing
Deliver the RVW V4.0 journal configuration center across backend, frontend, migration, and docs with zh/en editorial baseline support and tenant-level prompt/template overrides. Unify tenant login to /:tenantCode/login and auto-enable RVW module when tenant type is JOURNAL to prevent post-login access gaps.

Made-with: Cursor
2026-03-15 11:51:35 +08:00

50 lines
1.8 KiB
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- RVW V4.0 期刊配置中心 MVP
-- 一次性补齐 tenants(P0/P1/P2+language) 与 tenant_rvw_configs(4维Prompt+Template)
-- 1) 枚举JournalLanguage
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1
FROM pg_type t
JOIN pg_namespace n ON n.oid = t.typnamespace
WHERE t.typname = 'JournalLanguage'
AND n.nspname = 'platform_schema'
) THEN
CREATE TYPE "platform_schema"."JournalLanguage" AS ENUM ('ZH', 'EN', 'OTHER');
END IF;
END $$;
-- 2) 枚举TenantType 增加 JOURNAL
DO $$
BEGIN
ALTER TYPE "platform_schema"."TenantType" ADD VALUE IF NOT EXISTS 'JOURNAL';
EXCEPTION
WHEN duplicate_object THEN NULL;
END $$;
-- 3) tenants 表新增字段
ALTER TABLE "platform_schema"."tenants"
ADD COLUMN IF NOT EXISTS "journal_language" "platform_schema"."JournalLanguage",
ADD COLUMN IF NOT EXISTS "journal_full_name" TEXT,
ADD COLUMN IF NOT EXISTS "logo_url" TEXT,
ADD COLUMN IF NOT EXISTS "brand_color" TEXT,
ADD COLUMN IF NOT EXISTS "login_background_url" TEXT;
ALTER TABLE "platform_schema"."tenants"
ALTER COLUMN "journal_language" SET DEFAULT 'ZH';
-- 4) tenant_rvw_configs 表升级为 Prompt/Template 统一结构
ALTER TABLE "platform_schema"."tenant_rvw_configs"
ADD COLUMN IF NOT EXISTS "editorial_base_standard" TEXT NOT NULL DEFAULT 'en',
ADD COLUMN IF NOT EXISTS "editorial_expert_prompt" TEXT,
ADD COLUMN IF NOT EXISTS "editorial_handlebars_template" TEXT,
ADD COLUMN IF NOT EXISTS "data_forensics_expert_prompt" TEXT,
ADD COLUMN IF NOT EXISTS "data_forensics_handlebars_template" TEXT,
ADD COLUMN IF NOT EXISTS "clinical_handlebars_template" TEXT;
ALTER TABLE "platform_schema"."tenant_rvw_configs"
DROP COLUMN IF EXISTS "editorial_rules",
DROP COLUMN IF EXISTS "data_forensics_level",
DROP COLUMN IF EXISTS "finer_weights";