Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
varanakonda opened this issue Apr 11, 2021 · 1 comment
Open

Comments

@varanakonda
Copy link

varanakonda commented Apr 11, 2021

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?

@dakotacookenmaster
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants