Skip to content

Commit 57888f0

Browse files
committed
fix(migrations): 显式写 now() 到 doc_paths.updated_at
生产 schema 里 doc_paths.updated_at 是 NOT NULL 但没 DB-level default (Prisma @updatedat 只在应用层维护),原生 INSERT 不填直接违反约束 跑挂了。改成 INSERT 时显式写 now(),本地 H2 和生产 PG 都 OK。
1 parent 333d2d6 commit 57888f0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

docs/migrations/2026-04-22-seed-ia-reorg-doc-paths.sql

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ ranked_matches AS (
6060
JOIN ia_reorg_aliases a ON d.path_current LIKE a.new_prefix || '%'
6161
WHERE d.path_current IS NOT NULL
6262
)
63-
INSERT INTO doc_paths (doc_id, path)
64-
SELECT doc_id, old_path
63+
-- updated_at 在生产 schema 里是 NOT NULL 但没 DB-level default(Prisma @updatedAt
64+
-- 是应用层维护,原生 INSERT 不会填),这里显式写 now() 兜底。
65+
INSERT INTO doc_paths (doc_id, path, created_at, updated_at)
66+
SELECT doc_id, old_path, now(), now()
6567
FROM ranked_matches
6668
WHERE rn = 1
6769
ON CONFLICT (doc_id, path) DO NOTHING;

0 commit comments

Comments
 (0)