// {app_root}/app.js
module.exports = app => {
app.beforeStart(async () => {
// 从配置中心获取 MySQL 的配置
// { host: 'mysql.com', port: '3306', user: 'test_user', password: 'test_password', database: 'test' }
await app.model.sync({ force: true });
});
};
- force为true 每次都会删除表重建,false会检测代码中创建的model文件在程序执行时创建表