feat(server): 使用sequelize.sync({ alter: true }),不管了

This commit is contained in:
dayjoy
2025-09-12 11:01:39 +08:00
parent 9a7549d18c
commit 3be454ce38

View File

@@ -12,6 +12,7 @@ import expressOasGenerator, {
dotenv.config({ path: path.resolve(__dirname, "../../../.env") }); dotenv.config({ path: path.resolve(__dirname, "../../../.env") });
import "./database"; import "./database";
import { sequelize } from '@/database'
import { createApis } from "./api"; import { createApis } from "./api";
const port = process.env.PORT || 3005; const port = process.env.PORT || 3005;
@@ -50,6 +51,12 @@ app.get("/v3/api-docs", async (req, res) => {
}); });
const host = "0.0.0.0"; const host = "0.0.0.0";
app.listen(Number(port), host, () => { app.listen(Number(port), host, async () => {
try {
await sequelize.sync({ alter: true });
console.log('[server]: sequelize.sync() executed');
} catch (e) {
console.error('Failed to sync database:', e);
}
console.log(`[server]: Server is running at http://${host}:${port}`); console.log(`[server]: Server is running at http://${host}:${port}`);
}); });