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

Already on GitHub? Sign in to your account

--migration-dir option ignored when creating migrations #47

gilbo opened this Issue Sep 11, 2012 · 3 comments


None yet
2 participants

gilbo commented Sep 11, 2012

The following command:

./node_modules/db-migrate/bin/db-migrate create sample --migrations-dir components/database/migrations

will correctly create the components/database/migrations directory if it doesn't yet exist. But, it will then try to open


instead of


I looked at the code and figured out that the directory option isn't even getting passed to the index.createMigration() call. It also isn't getting stored away anywhere else. Instead the function formatPath() in migration.js has a path hard-coded in:

function formatPath(name) {
  return process.cwd() + '/migrations/' + name + '.js';

I didn't want to try to fix the issue myself since I imagine you might have a preferred way to do so.


kunklejr commented Sep 14, 2012

You're right, this is definitely a problem. I'm also thinking about adding a config file option to specify the migrations directory so you don't have to type it in every time when you're deviating from the default. I'm assuming that would be useful, correct?

gilbo commented Sep 15, 2012

Since there's already a way to specify the directory via the command line option, that should probably work regardless. That would also keep you consistent with the node-migrate interface.

I guess it depends on the user whether they would find a config file useful. Since the command has so few options right now, it seems like overkill. In my case, this would be integrated into a larger build/maintenance system, so the command is invoked via a script anyway. I'll have my own project config file, so adding another config file would just make things messier for me.

Also, if you add a config file, you might just be back at square one, cause then you get all the joys of defining when and how the config file is used vs. command line parameters and where exactly the program will search for a config file. Sticking with the command line option makes the execution context more obvious for the user.

But still, just my opinion. Maybe someone else would find a config file very useful.


Oh duh! I just realized that there's already a config file... DOH! Probably a great idea to add the option there too then. Sorry for the ramble.

@kunklejr kunklejr closed this in 2184b58 Sep 17, 2012


kunklejr commented Sep 17, 2012

Fix is in version 0.2.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment