disable synchronize when typeorm db init, all schema change depend on migration

This commit is contained in:
geekgeekrun
2025-05-03 15:03:25 +08:00
parent 5174da2c6c
commit 6986fbdc3c
5 changed files with 82 additions and 41 deletions

View File

@@ -1,6 +1,7 @@
import "reflect-metadata";
import { type DataSource } from "typeorm";
import { requireTypeorm } from "./utils/module-loader";
import fs from 'node:fs'
import { BossInfo } from "./entity/BossInfo";
import { BossInfoChangeLog } from "./entity/BossInfoChangeLog";
@@ -33,7 +34,7 @@ export function initDb(dbFilePath) {
const { DataSource } = requireTypeorm()
const appDataSource = new DataSource({
type: "sqlite",
synchronize: true,
synchronize: !fs.existsSync(dbFilePath),
logging: true,
logger: "simple-console",
database: dbFilePath,