sequelize-mig icon indicating copy to clipboard operation
sequelize-mig copied to clipboard

Can't find sequelize index file. Use `sequelize init` to create it

Open varanakonda opened this issue 3 years ago • 1 comments

When I run ./node_modules/.bin/sequelize-mig migration:make: I have an error:

Can't find sequelize index file. Use sequelize init to create it

But ./node_modules/.bin/sequelize init:

ERROR: The file src/database/config.js already exists. Run command with --force to overwrite it.

.sequelizerc:

const path = require('path')
const dir = process.env.NODE_ENV === 'production' ? 'dist/database' : 'src/database'

module.exports = {
    'config': path.resolve(dir, 'config.js'),
    'models-path': path.resolve(dir, 'models'),
    'seeders-path': path.resolve(dir, 'seeders'),
    'migrations-path': path.resolve(dir, 'migrations'),
}

How to fix it?

varanakonda avatar Apr 11 '21 17:04 varanakonda

As far as I am aware, the index.js file generated by sequelize-cli should automatically be created in your models folder by running sequelize init. When you run sequelize-mig migration:make, do you specify where your models folder is, since it likely won't be using your .sequelizerc file? Since sequelize-mig uses the path /models by default, you'll want to run the following command instead:

./node_modules/.bin/sequelize-mig migration:make --models-path ./path/to/your/models

dakotacookenmaster avatar Jun 24 '21 14:06 dakotacookenmaster