-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
What problem does this feature solve
umzug: https://github.com/sequelize/umzug
umzug 管理数据库的 migration 和 seeds 的优势
- 不局限于 orm 框架
- 数据路径: 可自由选定
- 操作记录: 存储可以放在数据库,也可以本地 json 文件保存
- 文件格式: 可以是 sql 文件,也可以是 js, ts 文件
- 精细管理: 可以是 一直 up, 或者 down, 也可以是 up / down 任意一个,也可以是任意范围
- 日志管理: 清晰管理和记录日志,日志库可以选定任意 logger, 可以是 log4js, winston 或者 pino, 也可以自定义
What does the proposed API look like
umzug migrate 例子: https://github.com/sequelize/umzug/blob/main/examples
普通形式的 migration
源码路径: https://github.com/sequelize/umzug/blob/main/examples/0-vanilla/migrate.js
migrate.js
const { Umzug, JSONStorage } = require('umzug');
exports.migrator = new Umzug({
migrations: {
glob: 'migrations/*.js',
},
context: { directory: __dirname + '/ignoreme' },
storage: new JSONStorage({ path: __dirname + '/ignoreme/storage.json' }),
logger: console,
});
if (require.main === module) {
exports.migrator.runAsCLI();
}node 直接运行 migrate.js
node migrate --help # show CLI help
node migrate up # apply migrations
node migrate down # revert the last migration
node migrate create --name new-migration.js # create a new migration file
node migrate up # apply migrations again
node migrate down --to 0 # revert all migrationsMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request