-
I apologize if this isn't a bug. "umzug": "^3.1.0",
"sequelize": "^6.17.0", I have migrations in typescript that are ran via ts-node in dev and are compiled via tsc before being run in production. Effectively, this means if I use the same database in dev and then production (say, to test behavior) the migrations run twice because the const umzug = new Umzug({
migrations: {
glob:
process.env.NODE_ENV === "production"
? __dirname + "/migrations/*.js"
: __dirname + "/migrations/*.ts"
},
context: sequelize.getQueryInterface(),
storage: new SequelizeStorage({ sequelize }),
logger: console
}) and the contents of SequelizeMeta after running in dev then production: # run in production
1 | 00_user-table.js
2 | 01_user-add-role.js
3 | 02_post_table.js
4 | 03_files_table.js
5 | 04_post_authors_table.js
# then run as dev
6 | 00_user_table.ts # <-- this is the same as 00_user-table.js |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
My first instinct is to strongly recommend not using the same database for development and production 🙃 But since this isn't stack overflow, here's one way you could do this using a custom const umzug = new Umzug({
migrations: {
glob:
process.env.NODE_ENV === "production"
? __dirname + "/migrations/*.js"
: __dirname + "/migrations/*.ts",
resolve: params => {
const defaultResolver = Umzug.defaultResolver(params)
return {
...defaultResolver,
name: defaultResolver.name.replace(/\.(js|ts)$/, ''),
}
},
},
context: sequelize.getQueryInterface(),
storage: new SequelizeStorage({ sequelize }),
logger: console
}) |
Beta Was this translation helpful? Give feedback.
My first instinct is to strongly recommend not using the same database for development and production 🙃
But since this isn't stack overflow, here's one way you could do this using a custom
resolve
function that wraps the default one: