0

I am using rethinkdb-migrate for migrating rethink db database object.

I am running the following command -

rethinkdb-migrate up --db=test 

When the migration file is in migrations folder it's working as expected. but when I am moving the migration folder within another folder ( db ), it's not working.

rethinkdb-migrate up --file /db/migrations/20180725062631-scehma.js --db=test

The above command gives following error -

/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/node_modules/yargs/yargs.js:1133
      else throw err
           ^

Error: Cannot find module '/db/migrations/20180725062631-scehma.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at readOptionsFile (/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/bin/rethinkdb-migrate:140:10)
    at buildOptions (/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/bin/rethinkdb-migrate:120:21)
    at runMigrations (/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/bin/rethinkdb-migrate:96:19)
    at Object.runCommand (/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/node_modules/yargs/lib/command.js:235:44)
    at Object.parseArgs [as _parseArgs] (/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/node_modules/yargs/yargs.js:1046:30)
    at Object.get [as argv] (/home/bappaditya/.nvm/versions/node/v8.11.3/lib/node_modules/rethinkdb-migrate/node_modules/yargs/yargs.js:989:21)

I triple checked, 20180725062631-scehma.js exists in db/migrations

ajtrichards
  • 29,723
  • 13
  • 94
  • 101
Bopsi
  • 2,090
  • 5
  • 36
  • 58

2 Answers2

0

Maybe you have misspelled the name of the file, "-scehma" to "-schema" :

rethinkdb-migrate up --file /db/migrations/20180725062631-scehma.js --db=test

It should be:

rethinkdb-migrate up --file /db/migrations/20180725062631-schema.js --db=test
-1

Unless your db folder is in the root, you shouldn't use the leading slash.

So instead of:

rethinkdb-migrate up --file /db/migrations/20180725062631-scehma.js --db=test

Use:

rethinkdb-migrate up --file db/migrations/20180725062631-scehma.js --db=test
Cobus Kruger
  • 8,338
  • 3
  • 61
  • 106
  • tried that too, it's giving me an error - Error: Cannot find module '/db/migrations/20180725062631-scehma.js' – Bopsi Aug 07 '18 at 09:27
  • I did a test with an empty schema file, and if it can find the file at all, it will attempt to connect - even before checking if the file is trash, like mine. I suggest copying the module name from that output and doing an `ls`. Almost certainly, that's not going to show your file. – Cobus Kruger Aug 07 '18 at 09:38