From 93e28992704d690f2686e375845cdf5db4611c7a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:06:44 +0000 Subject: [PATCH 1/2] Initial plan From 54567a49d10a369596b66e925df8031e0abe55cf Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 29 Jan 2026 12:08:59 +0000 Subject: [PATCH 2/2] Use content hash instead of filename for migration tracking Co-authored-by: 0ghost0-dev <70481054+0ghost0-dev@users.noreply.github.com> --- src/lib/server/postgresql/db.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/server/postgresql/db.ts b/src/lib/server/postgresql/db.ts index f775164..54d54a2 100644 --- a/src/lib/server/postgresql/db.ts +++ b/src/lib/server/postgresql/db.ts @@ -4,6 +4,7 @@ import { logger } from "../../../utils/logger"; import { type PJSe } from '../loader/loader'; import { readdir, readFile } from 'fs/promises'; import { join } from 'path'; +import { createHash } from 'crypto'; const encodedPassword = encodeURIComponent(env.POSTGRESQL_PASSWORD); const dbUrl = `postgres://${env.POSTGRESQL_USER}:${encodedPassword}@${env.POSTGRESQL_HOST}:${env.POSTGRESQL_PORT}/${env.POSTGRESQL_NAME}`; @@ -64,9 +65,12 @@ export async function runMigrations(): Promise { const filePath = join(migrationFolder, file); const sql = await readFile(filePath, 'utf-8'); + // 파일 내용의 해시 계산 + const contentHash = createHash('sha256').update(sql).digest('hex'); + // 이미 실행된 마이그레이션인지 확인 const [existing] = await postgresClient` - SELECT id FROM drizzle_migrations WHERE hash = ${file} + SELECT id FROM drizzle_migrations WHERE hash = ${contentHash} `; if (!existing) { @@ -80,7 +84,7 @@ export async function runMigrations(): Promise { // 실행 기록 저장 await tx.unsafe( 'INSERT INTO drizzle_migrations (hash, created_at) VALUES ($1, $2)', - [file, Date.now()] + [contentHash, Date.now()] ); });