1
0
mirror of https://github.com/ZeroCatDev/ClassworksKV.git synced 2025-07-01 20:09:23 +00:00

Enhance database setup in classworks.js to include automatic migration execution after setting the DATABASE_URL. Update Dockerfile to use Node.js version 22-alpine for improved compatibility. Modify docker-compose.yml to change volume mapping for data storage.

This commit is contained in:
SunWuyuan 2025-05-24 20:00:17 +08:00
parent ee2787a413
commit 93b9b1c6f5
No known key found for this signature in database
GPG Key ID: A6A54CF66F56BB64
3 changed files with 10 additions and 3 deletions

View File

@ -1,4 +1,4 @@
FROM node:alpine
FROM node:22-alpine
WORKDIR /app

View File

@ -44,6 +44,13 @@ function setupDatabase() {
// 设置 Prisma 的 DATABASE_URL
process.env.DATABASE_URL = DATABASE_URL;
// 检查数据库表并执行必要的迁移
execSync(
"npx prisma migrate dev --name update-" +
new Date().toISOString().split("T")[0],
{ stdio: "inherit" }
);
} catch (error) {
console.error("❌ 数据库初始化失败:", error.message);
process.exit(1);

View File

@ -13,5 +13,5 @@ services:
- DATABASE_TYPE=sqlite
- DATABASE_URL=
volumes:
- cs-data:/data
- .data:/app/data