Merge pull request #11 from d0zingcat/fix/db-migrate

This commit is contained in:
2026-01-15 21:12:13 +08:00
committed by GitHub
3 changed files with 20 additions and 2 deletions

View File

@@ -5,6 +5,11 @@
本文件的格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/) 本文件的格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/)
并且本项目遵循 [语义化版本 (Semantic Versioning)](https://semver.org/lang/zh-CN/spec/v2.0.0.html)。 并且本项目遵循 [语义化版本 (Semantic Versioning)](https://semver.org/lang/zh-CN/spec/v2.0.0.html)。
## [1.2.7] - 2026-01-15
### 修复
- **数据库迁移**:修复了在 K8s 环境下执行 `db:migrate:deploy` 时由于相对路径解析失败导致的迁移中断问题。现在使用绝对路径进行稳健解析,并增加了调试日志。
## [1.2.6] - 2026-01-15 ## [1.2.6] - 2026-01-15
### 变更 ### 变更

View File

@@ -1,3 +1,6 @@
import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { eq } from "drizzle-orm"; import { eq } from "drizzle-orm";
import { drizzle } from "drizzle-orm/postgres-js"; import { drizzle } from "drizzle-orm/postgres-js";
import { migrate } from "drizzle-orm/postgres-js/migrator"; import { migrate } from "drizzle-orm/postgres-js/migrator";
@@ -42,8 +45,18 @@ async function main() {
const sql = postgres(connectionString, { max: 1 }); const sql = postgres(connectionString, { max: 1 });
const db = drizzle(sql, { schema }); const db = drizzle(sql, { schema });
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const migrationsFolder = path.resolve(__dirname, "../../drizzle");
console.log(`📂 Migrations folder: ${migrationsFolder}`);
if (!fs.existsSync(migrationsFolder)) {
console.error(`❌ Migrations folder not found: ${migrationsFolder}`);
process.exit(1);
}
try { try {
await migrate(db, { migrationsFolder: "./drizzle" }); await migrate(db, { migrationsFolder });
console.log("✅ Database migrations completed!"); console.log("✅ Database migrations completed!");
await migrateUserTokens(db); await migrateUserTokens(db);

View File

@@ -1,4 +1,4 @@
# Project Context for GitHub Copilot (v1.2.6) # Project Context for GitHub Copilot (v1.2.7)
This document provides technical context, architectural decisions, and code conventions for the **Alert Message Center** project. It is intended to help AI assistants understand the codebase. This document provides technical context, architectural decisions, and code conventions for the **Alert Message Center** project. It is intended to help AI assistants understand the codebase.