sequelize / cli

The Sequelize CLI
MIT License
2.53k stars 529 forks source link

Migration undo command didn't work correctly. #1457

Closed KumaKode closed 7 months ago

KumaKode commented 7 months ago

What you are doing?

I run the following command in my project root directory npx sequelize db:migrate:undo, but it failed to find the migration file in my project src folder and pointing to the last migration file, thus it give this error:

image

This is the migration file in my project src migration folder which i want to undo:

image

My .sequelizerc code:

// code here
require("dotenv").config();
const path = require("path");
// prettier-ignore
module.exports = {
  'config': path.resolve('src/config', 'config.js'),
  'models-path': path.resolve('src', 'models'),
  'seeders-path': path.resolve('src', 'seeders'),
  'migrations-path': path.resolve('src', 'migrations')
};

My config.js code:

require("dotenv").config();
const isDocker = require("./is-docker");

console.log(isDocker());

// prettier-ignore
module.exports = {
  "development": {
    "username": process.env.DB_USER,
    "password": process.env.DB_PASS,
    "database": process.env.DB_NAME,
    "host": isDocker() ? process.env.DB_HOST : "127.0.0.1",
    "dialect": "mysql"
},
"test": {
    "username": "root",
    "password": null,
    "database": "database_test",
    "host": "127.0.0.1",
    "dialect": "mysql"
},
"production": {
    "username": "root",
    "password": null,
    "database": "database_production",
    "host": "127.0.0.1",
    "dialect": "mysql"
}
};

What do you expect to happen?

I want it to successfully undo the migration, which is presented in the migration fodler

What is actually happening?

image

Dialect: mysql Sequelize CLI version: 6.35.2 __Sequelize version: 6.6.2

KumaKode commented 7 months ago

My sincere apologies You can use db:migrate:undo, this command will revert the most recent migration. I forgot to follow this.