There are a lot of posts on sequelize migration file access through the sequilize-cli file structure. However, if I am not using the sequilize-cli, how does one locate the migration file?
Asked
Active
Viewed 7,433 times
1 Answers
9
Well, in order to work with migrations and run them, you will need to use sequelize-cli
, you can run the command sequelize init
which will initialize the folders/files needed to work with the cli.
However, you can ignore that step by using your own structure and creating a file named .sequelizerc
where you will place your migrations/seeds, for example mine looks like the folowing:
const path = require('path')
module.exports = {
'config': path.resolve('config', 'db.json'),
'migrations-path': path.resolve('db', 'migrate'),
'seeders-path': path.resolve('db', 'seeders')
}
So if I run sequelize db:migrate
the cli will automatically look for the migrations in the db/migrate folder

Omar Vazquez
- 407
- 4
- 14
-
1Where do you locate the db/migration folder? – Val Mar 02 '17 at 03:49
-
It's not a standard as far as I know, I recommend you to place the `db` folder in the root directory of your app. I like [Ruby on Rails structure](https://www.tutorialspoint.com/ruby-on-rails/rails-directory-structure.htm) so I try to follow it at least while using express (as it gives you freedom on where you place your stuff), but you can choose the location you want – Omar Vazquez Mar 02 '17 at 04:15
-
I discovered the migration folder in the main server file. Sequelize-CLI installs in the server root dir "config", "migrations" and "seeders". What I don't understand with your response is the relevance of the db folder and where the .sequelizerc folder should be placed. Can you please update your answer to more clearly express your solution? – Val Mar 02 '17 at 06:31
-
It always says "Unkown argument: migrations-path" when I use a .squelizerc file. I tested all the paths and they are ok. – Roel Mar 22 '19 at 13:44
-
Aargh it called migrations-source-path when using typescript! – Roel Mar 22 '19 at 13:51
-
This saved me after spending several hours lost on how sequelize-cli was supposed to work when you use the bootstrapper in a different subdirectory. My target directory names were a little different. For anyone else passing through, here's the doc: https://sequelize.org/master/manual/migrations.html#the--code--sequelizerc--code--file – Joe Sadoski Jan 28 '21 at 22:28