fix(db): enable test env cold-start migrations on empty database.
Use pgvector image with extensions-only init, seed legacy users before project/chat fixtures, and align test compose with goose-only schema bootstrap. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
weichen
co-authored by
Cursor
parent
f73988e567
commit
72879c6e22
@@ -0,0 +1,3 @@
|
||||
-- 各环境 Postgres 容器首次启动时仅安装扩展;业务表由 goose 迁移链创建。
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
||||
@@ -2,6 +2,13 @@
|
||||
-- 10 个示例医疗器械项目数据初始化脚本 (针对项目评审全流程落地)
|
||||
BEGIN;
|
||||
|
||||
-- 空库冷启动:确保 creator_user_id=1 的外键目标存在(IAM 种子在后续迁移中补齐)
|
||||
INSERT INTO users (id, account_id, name, role) VALUES
|
||||
(1, 'seed-admin', 'Seed Admin', 'engineer'),
|
||||
(2, 'seed-zhanggong', '张工', 'engineer'),
|
||||
(3, 'seed-lizhuguan', '李主管', 'engineer')
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
INSERT INTO projects (id, code, name, customer_name, device_type, intended_use, target_market, current_stage, environment, status, creator_user_id, active_workflow_key, workflow_selection_version, created_at, updated_at)
|
||||
VALUES (6001, 'PROJ-WANGJING-0021', '膝骨关节炎综合治疗仪', '中国中医科学院望京医院骨伤科', '中药离子导入与多频温控电热综合治疗设备', '用于早中期膝骨关节炎患者的局部经皮靶向定向透药导入、穴位多频电刺激止痛与温热理疗', '中国 NMPA II类 (YY 0601-2007 中药定向透药治疗仪, GB 9706.1-2020, YY 0505-2012)', 'V0.5', 'dev', 'active', 1, 'main', 1, now(), now())
|
||||
ON CONFLICT (id) DO UPDATE SET
|
||||
|
||||
@@ -9,7 +9,7 @@ name: agent-test
|
||||
|
||||
services:
|
||||
system-db:
|
||||
image: postgres:16-alpine
|
||||
image: pgvector/pgvector:pg16
|
||||
container_name: shuimu-system-pg-test
|
||||
command: ["postgres", "-c", "shared_buffers=256MB", "-c", "max_connections=150"]
|
||||
environment:
|
||||
@@ -20,7 +20,7 @@ services:
|
||||
- "127.0.0.1:${SYSTEM_DB_PUBLISH_PORT:-5434}:5432"
|
||||
volumes:
|
||||
- test-system-pgdata:/var/lib/postgresql/data
|
||||
- ./deploy/postgres/system_init.sql:/docker-entrypoint-initdb.d/01-init.sql:ro
|
||||
- ./deploy/postgres/extensions_init.sql:/docker-entrypoint-initdb.d/01-extensions.sql:ro
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${SYSTEM_DB_USER:-app} -d ${SYSTEM_DB_NAME:-agent_system_test}"]
|
||||
interval: 5s
|
||||
|
||||
Reference in New Issue
Block a user