db-migrate / node-db-migrate

Database migration framework for node
Other
2.32k stars 360 forks source link

Sending in Options for getInstance doesn't seem to do anything #767

Closed dschinkel closed 2 years ago

dschinkel commented 2 years ago

Now, I'm sure I have this wrong. Yes I've looked at your docs Yes it's probably something stupid I'm missing but I need another set of eyes on this

Am I passing the key/value pairs in terms of what your API expects as in structure here?

const dbmigrate = DBMigrate.getInstance(true, {
    config: 'database.json',
    env: 'dev',
    cmdOptions: {
        m: './migrations',
    },
});

https://db-migrate.readthedocs.io/en/latest/API/programable

Options

cwd - working directory (default: process.cwd)
config
string - location of the database.json file
object - hash of [configuration](https://umigrate.readthedocs.org/projects/db-migrate/en/latest/Getting%20Started/configuration/) options
cmdOptions - hash of CMD options from [Basic Usage](https://db-migrate.readthedocs.io/en/latest/Getting%20Started/installation/)

So I added an object literal for options but doesn't seem like any of this is quite right in terms of structure in mine so can you verify my structure. I need to be able to specify migrations-dir which in this object I just keyed it with an m.

the migrations directory is at the same level as my database.json. And I am running the dbMigrate command from that same directory as well.

Also tried:

cmdOptions: {
  'migrations-dir': '.',
},

and

cmdOptions: {
  'migrations-dir': './migrations',
},
dschinkel commented 2 years ago

related 557

dschinkel commented 2 years ago

figured it out finally

const dbmigrate = DBMigrate.getInstance(true, {
  config: path.join(__dirname, './database.json'),
  env: 'dev',
  cmdOptions: {
    'migrations-dir': path.join(__dirname, '/migrations/test'),
  },
});