ESM & sequelize db:migrate
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, node.js
Research direction
Start by running npx sequelize db:migrate with the migration shown in db/migrations/20220924162319-create-test.js, then inspect the module-loading path reported in umzug/lib/migration.js. Compare the CLI's handling of CommonJS and ESM migrations; done means the example migration runs successfully without the require() error.
Written by the indexing model from the issue text.
Description
It would be great if sequelize-cli supports migrations in ESM way.
What you are doing?
// db/migrations/20220924162319-create-test.js
export async function up(queryInterface, Sequelize) {
await queryInterface.createTable('test', {
id: {
type: Sequelize.DataTypes.INTEGER,
allowNull: false,
autoIncrement: true,
primaryKey: true,
},
createdAt: {
allowNull: false,
type: Sequelize.DataTypes.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DataTypes.DATE,
}
});
}
export function down(queryInterface, Sequelize) {
return queryInterface.dropTable('test');
}
npx sequelize db:migrate
What do you expect to happen?
Migration works.
What is actually happening?
npx sequelize db:migrate
Sequelize CLI [Node: 16.16.0, CLI: 6.4.1, ORM: 6.23.0]
Loaded configuration file "db/config.js".
== 20220924162319-create-test: migrating =======
ERROR: require() of ES Module /test/db/migrations/20220924162319-create-test.js from /test/node_modules/umzug/lib/migration.js not supported.
Instead change the require of 20220924162319-create-test.js in /test/node_modules/umzug/lib/migration.js to a dynamic import() which is available in all CommonJS modules.
Output, either JSON or SQL
Dialect: postgres
Database version: 12
Sequelize CLI version: 6.4.1
Sequelize version: 6.23.0
- Dominant language
- JavaScript
- Stars
- 2.6k
- Forks
- 524
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sequelize/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
HarperFast/skills#96 ·
-
[Block] Latest Posts [Type] Bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Automattic/studio#4908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
sugarlabs/musicblocks#8847 ·