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:
@@ -161,7 +161,8 @@ test('admin login users grant and audit with mocked API', async ({ page }) => {
|
|||||||
await ok({})
|
await ok({})
|
||||||
})
|
})
|
||||||
|
|
||||||
await page.goto('/login')
|
// Leading `/login` would resolve to host root and miss Vite base `/psy/admin/`.
|
||||||
|
await page.goto('login')
|
||||||
await expect(page.getByRole('heading', { name: '愈心谷' })).toBeVisible()
|
await expect(page.getByRole('heading', { name: '愈心谷' })).toBeVisible()
|
||||||
await page.locator('input[type="password"]').fill('change-me')
|
await page.locator('input[type="password"]').fill('change-me')
|
||||||
await page.getByRole('button', { name: '登录' }).click()
|
await page.getByRole('button', { name: '登录' }).click()
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { defineConfig, devices } from '@playwright/test'
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Ops admin L3 smoke: Vite preview + mocked /api/v1/admin (no Go required).
|
* Ops admin L3 smoke: Vite preview + mocked /api/v1/admin (no Go required).
|
||||||
|
* Build uses base `/psy/admin/` — baseURL must include that prefix.
|
||||||
* Run: npm run test:e2e -w @yuxingu/admin-h5
|
* Run: npm run test:e2e -w @yuxingu/admin-h5
|
||||||
*/
|
*/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
@@ -10,7 +11,8 @@ export default defineConfig({
|
|||||||
forbidOnly: !!process.env.CI,
|
forbidOnly: !!process.env.CI,
|
||||||
retries: process.env.CI ? 1 : 0,
|
retries: process.env.CI ? 1 : 0,
|
||||||
use: {
|
use: {
|
||||||
baseURL: 'http://127.0.0.1:4174',
|
// Trailing slash so relative goto('login') resolves under /psy/admin/
|
||||||
|
baseURL: 'http://127.0.0.1:4174/psy/admin/',
|
||||||
trace: 'on-first-retry',
|
trace: 'on-first-retry',
|
||||||
},
|
},
|
||||||
projects: [
|
projects: [
|
||||||
@@ -24,7 +26,7 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
webServer: {
|
webServer: {
|
||||||
command: 'npm run build && npm run preview -- --host 127.0.0.1 --port 4174',
|
command: 'npm run build && npm run preview -- --host 127.0.0.1 --port 4174',
|
||||||
url: 'http://127.0.0.1:4174',
|
url: 'http://127.0.0.1:4174/psy/admin/',
|
||||||
reuseExistingServer: false,
|
reuseExistingServer: false,
|
||||||
timeout: 120_000,
|
timeout: 120_000,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
## 2026-08-13
|
## 2026-08-13
|
||||||
|
|
||||||
|
- **Migration 撞号修复:** `000015`–`000023` 双文件冲突已重编号为唯一序列至 `000050`;说明见 `docs/MIGRATION_RENUMBER.md`
|
||||||
- **Merge:** `merge/ops-local-into-main` — 合并本地 Ops 目录扩展(ECR-013A…040)与远程 main(ECR-009…016)
|
- **Merge:** `merge/ops-local-into-main` — 合并本地 Ops 目录扩展(ECR-013A…040)与远程 main(ECR-009…016)
|
||||||
注意:分叉期间 ECR-012/014/015/016 编号在两边含义不同,以 TRACEABILITY 双列说明为准
|
注意:分叉期间 ECR-012/014/015/016 编号在两边含义不同,以 TRACEABILITY 双列说明为准
|
||||||
- **Git host:** 远程改为 `https://git.jackyu66.com/jack/digital-psychology.git`;删除 `.github/workflows`(不再使用 GitHub Actions)
|
- **Git host:** 远程改为 `https://git.jackyu66.com/jack/digital-psychology.git`;删除 `.github/workflows`(不再使用 GitHub Actions)
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
# Migration renumber — merge collision fix (2026-08-13)
|
||||||
|
|
||||||
|
## Problem
|
||||||
|
|
||||||
|
`main`(产品 ECR-009…016)与 Ops 线(ECR-013A…040)合并后,`000015`–`000023` **各有两套** migration。
|
||||||
|
本仓 `internal/db.Migrate` 以**完整文件名**为 version,两边都可能被执行,但同号双文件易误导运维,也不兼容 golang-migrate。重编号消除歧义并固定依赖顺序。
|
||||||
|
|
||||||
|
## Canonical sequence (after fix)
|
||||||
|
|
||||||
|
| Ver | Name | Origin |
|
||||||
|
|-----|------|--------|
|
||||||
|
| 015 | ops_commerce | main Ops-D |
|
||||||
|
| 016 | ops_system | main Ops-E |
|
||||||
|
| 017 | unique_self_profile | main ECR-011 |
|
||||||
|
| 018 | admin_rbac | Ops ECR-013A |
|
||||||
|
| 019 | account_lifecycle | Ops ECR-013B |
|
||||||
|
| 020 | membership_plans | Ops |
|
||||||
|
| 021 | redemption_codes | Ops |
|
||||||
|
| 022 | ask_ops_read | Ops |
|
||||||
|
| 023 | content_safety_filter | Ops |
|
||||||
|
| 024 | ask_quality_feedback | Ops |
|
||||||
|
| 025 | ai_system_prompts | Ops |
|
||||||
|
| 026 | crisis_policies | Ops |
|
||||||
|
| 027 | user_avatar | main ECR-015 |
|
||||||
|
| 028 | mbti_label | main |
|
||||||
|
| 029 | mbti_questions | main |
|
||||||
|
| 030 | oejts_mbti | main |
|
||||||
|
| 031 | mbti_full_60 | main |
|
||||||
|
| 032 | home_daily_tips | main ECR-014 |
|
||||||
|
| 033–050 | knowledge…ops_hardening | Ops ECR-023…040 + hardening |
|
||||||
|
|
||||||
|
`000001`–`000014` 未改。
|
||||||
|
|
||||||
|
## Fresh database
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# API 使用 internal/db.Migrate(version = 完整 stem,如 000018_admin_rbac)
|
||||||
|
cd apps/api && go run ./cmd/server # 或集成测试 setup 会 Migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
空库应写入 **50** 条 `schema_migrations`(已在 `yuxingu_mig_check` 验证)。
|
||||||
|
|
||||||
|
## Already-applied databases(必做)
|
||||||
|
|
||||||
|
本仓 version 键是 **完整文件名**(非纯数字)。重编号后若不改 `schema_migrations`,会把已执行过的 SQL **再跑一遍**。
|
||||||
|
|
||||||
|
对已有库先执行修复脚本:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
psql "$DATABASE_URL" -f scripts/repair-schema-migrations-renumber.sql
|
||||||
|
```
|
||||||
|
|
||||||
|
然后再启动 API / `Migrate`。
|
||||||
|
|
||||||
|
### A. 可丢弃的开发库
|
||||||
|
|
||||||
|
重建库后 Migrate。
|
||||||
|
|
||||||
|
### B. 需保留数据
|
||||||
|
|
||||||
|
1. 跑 `scripts/repair-schema-migrations-renumber.sql`
|
||||||
|
2. 再 Migrate(只会补尚未有的 stem)
|
||||||
|
3. 若曾手改脏数据,对照 `SELECT version FROM schema_migrations ORDER BY version` 与本表核对
|
||||||
|
|
||||||
|
分叉两边「同号不同义」时,必须以**实际 DDL**为准。
|
||||||
|
|
||||||
|
## Doc debt
|
||||||
|
|
||||||
|
ESS / Spec 里仍可能写旧号(如「migration 000015 = RBAC」)。以本文件与 `apps/api/migrations/` 文件名为准;后续 ECR 文档可逐步改引用。
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
| ECR-012-star | **(local)** 星座对齐收口(星盘 · outlook · 合盘) | **Implemented** | Spec star-profile · 分叉编号冲突,见 CHANGELOG merge 注 |
|
| ECR-012-star | **(local)** 星座对齐收口(星盘 · outlook · 合盘) | **Implemented** | Spec star-profile · 分叉编号冲突,见 CHANGELOG merge 注 |
|
||||||
| ECR-013 | **(main)** 探索 curated 题库 A 集 · 结果回看 | **Closed** | Spec explore-test · BD-2026-013 |
|
| ECR-013 | **(main)** 探索 curated 题库 A 集 · 结果回看 | **Closed** | Spec explore-test · BD-2026-013 |
|
||||||
| WAVE-0 | Ops Contract-First Foundation | **FROZEN** | `docs/WAVE0/` · HUMAN_REVIEW FREEZE |
|
| WAVE-0 | Ops Contract-First Foundation | **FROZEN** | `docs/WAVE0/` · HUMAN_REVIEW FREEZE |
|
||||||
| ECR-013A | Admin RBAC | **Closed** | Spec ops-rbac · BD-2026-013A · migration 000015 |
|
| ECR-013A | Admin RBAC | **Closed** | Spec ops-rbac · BD-2026-013A · migration **000018**(原撞号 015,见 MIGRATION_RENUMBER) |
|
||||||
| ECR-013B | AccountLifecycle | **Closed** | Spec ops-account-lifecycle · BD-2026-013B |
|
| ECR-013B | AccountLifecycle | **Closed** | Spec ops-account-lifecycle · BD-2026-013B |
|
||||||
| ECR-014 | **(main)** 时效刷新(时辰贴士 · star/rhythm 按日) | **Closed** | RETRO · BD-2026-014 |
|
| ECR-014 | **(main)** 时效刷新(时辰贴士 · star/rhythm 按日) | **Closed** | RETRO · BD-2026-014 |
|
||||||
| ECR-014-plan | **(local)** MembershipPlan | **Closed** | Spec ops-membership-plan · 分叉编号冲突 |
|
| ECR-014-plan | **(local)** MembershipPlan | **Closed** | Spec ops-membership-plan · 分叉编号冲突 |
|
||||||
@@ -53,3 +53,5 @@
|
|||||||
| ECR-038 | GrowthInsights · ReportTemplate | **Closed** | Spec ops-report-template.md · BD-2026-038 |
|
| ECR-038 | GrowthInsights · ReportTemplate | **Closed** | Spec ops-report-template.md · BD-2026-038 |
|
||||||
| ECR-039 | GrowthInsights · FunnelDefinition | **Closed** | Spec ops-funnel-definition.md · BD-2026-039 |
|
| ECR-039 | GrowthInsights · FunnelDefinition | **Closed** | Spec ops-funnel-definition.md · BD-2026-039 |
|
||||||
| ECR-040 | ExploreConfig · ScaleDefinition | **Closed** | Spec ops-scale-definition.md · BD-2026-040 |
|
| ECR-040 | ExploreConfig · ScaleDefinition | **Closed** | Spec ops-scale-definition.md · BD-2026-040 |
|
||||||
|
|
||||||
|
> **Migration:** 合并后 `000015`–`000023` 曾撞号,已重编号至 `000050`。以 `apps/api/migrations/` 与 `docs/MIGRATION_RENUMBER.md` 为准(文档中旧号引用可能滞后)。
|
||||||
|
|||||||
@@ -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;
|
||||||
Reference in New Issue
Block a user