mirror of
https://github.com/patdelphi/suanming.git
synced 2026-03-10 02:23:12 +08:00
fix: Improve database persistence in Koyeb deployment
- Remove forced database initialization from Dockerfile CMD - App now auto-initializes database on startup without data loss - Skip sample data creation in production environment - Ensure admin user exists in production without recreating - Fixes database reset issue on every Koyeb deployment - Maintains data persistence with proper volume mounting
This commit is contained in:
@@ -38,8 +38,12 @@ async function initializeDatabase() {
|
||||
console.log('ℹ️ 管理员用户已存在');
|
||||
}
|
||||
|
||||
// 创建示例数据(可选)
|
||||
await createSampleData(db);
|
||||
// 仅在开发环境创建示例数据
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
await createSampleData(db);
|
||||
} else {
|
||||
console.log('ℹ️ 生产环境,跳过示例数据创建');
|
||||
}
|
||||
|
||||
console.log('🎉 数据库初始化完成!');
|
||||
console.log(`📍 数据库文件位置: ${path.resolve('./numerology.db')}`);
|
||||
|
||||
Reference in New Issue
Block a user