fix(db): 重编号合并后撞号 migration,并修 admin e2e base

将 015–023 双文件冲突线性化为 015–050;提供已有库 schema_migrations 修复脚本;admin Playwright 对齐 /psy/admin/ 预览路径。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
jackyu66git
2026-08-13 02:14:52 +08:00
co-authored by Cursor
parent 0d50c0ee73
commit b7b0b18802
72 changed files with 133 additions and 4 deletions
@@ -0,0 +1,54 @@
-- Repair schema_migrations after 2026-08-13 renumber (filename stems).
-- Safe to re-run. If new stem already exists, drops the obsolete old stem.
-- See docs/MIGRATION_RENUMBER.md
BEGIN;
CREATE TEMP TABLE _mig_rename(old_v text PRIMARY KEY, new_v text NOT NULL) ON COMMIT DROP;
INSERT INTO _mig_rename(old_v, new_v) VALUES
('000015_admin_rbac', '000018_admin_rbac'),
('000016_account_lifecycle', '000019_account_lifecycle'),
('000017_membership_plans', '000020_membership_plans'),
('000018_redemption_codes', '000021_redemption_codes'),
('000019_ask_ops_read', '000022_ask_ops_read'),
('000020_content_safety_filter', '000023_content_safety_filter'),
('000021_ask_quality_feedback', '000024_ask_quality_feedback'),
('000022_ai_system_prompts', '000025_ai_system_prompts'),
('000023_crisis_policies', '000026_crisis_policies'),
('000018_user_avatar', '000027_user_avatar'),
('000019_mbti_label', '000028_mbti_label'),
('000020_mbti_questions', '000029_mbti_questions'),
('000021_oejts_mbti', '000030_oejts_mbti'),
('000022_mbti_full_60', '000031_mbti_full_60'),
('000023_home_daily_tips', '000032_home_daily_tips'),
('000024_knowledge_sources', '000033_knowledge_sources'),
('000025_ops_banners', '000034_ops_banners'),
('000026_ops_feed_slots', '000035_ops_feed_slots'),
('000027_ops_scheduled_publications', '000036_ops_scheduled_publications'),
('000028_knowledge_chunks', '000037_knowledge_chunks'),
('000029_tool_definitions', '000038_tool_definitions'),
('000030_block_policies', '000039_block_policies'),
('000031_moderation_cases', '000040_moderation_cases'),
('000032_crisis_events', '000041_crisis_events'),
('000033_intervention_outcomes', '000042_intervention_outcomes'),
('000034_ask_handoff_cases', '000043_ask_handoff_cases'),
('000035_privacy_requests', '000044_privacy_requests'),
('000036_star_configs', '000045_star_configs'),
('000037_rhythm_configs', '000046_rhythm_configs'),
('000038_image_card_decks', '000047_image_card_decks'),
('000039_report_templates', '000048_report_templates'),
('000040_funnel_definitions', '000049_funnel_definitions'),
('000041_ops_hardening', '000050_ops_hardening');
-- Prefer keeping new_v if both exist; otherwise rename old -> new.
DELETE FROM schema_migrations sm
USING _mig_rename r
WHERE sm.version = r.old_v
AND EXISTS (SELECT 1 FROM schema_migrations x WHERE x.version = r.new_v);
UPDATE schema_migrations sm
SET version = r.new_v
FROM _mig_rename r
WHERE sm.version = r.old_v;
COMMIT;