47 lines
1.1 KiB
JavaScript

'use strict';
/**
* sequelize-cli 配置入口(`.sequelizerc` 指到这里)
*
* 连接信息与后端运行时**完全同源**:环境变量 > config/config.local.js > 默认值,
* 统一由 scripts/db-config.js 解析,避免迁移改到一个库、服务连另一个库。
*
* 用法:
* npm run db:migrate # 执行全部未执行的迁移
* npm run db:migrate:undo # 回滚最后一条
* npm run db:migrate:status # 查看状态
*/
const resolveDbConfig = require('../scripts/db-config');
const resolved = resolveDbConfig();
const common = {
username: resolved.user,
password: resolved.password,
database: resolved.database,
host: resolved.host,
port: resolved.port,
dialect: 'mysql',
timezone: '+08:00',
charset: 'utf8mb4',
logging: false,
define: {
freezeTableName: true,
underscored: true,
createdAt: 'created_at',
updatedAt: 'updated_at',
},
dialectOptions: {
// 与运行时保持一致(长文本/JSON 字段不被截断)
supportBigNumbers: true,
bigNumberStrings: true,
},
};
module.exports = {
development: common,
test: common,
production: common,
};