JohanObrink / rethink-migrate

A migration tool for rethink db
MIT License
47 stars 24 forks source link

rethink-migrate down fails to remove #7

Open amir-rahnama opened 8 years ago

amir-rahnama commented 8 years ago

I tried to run rethink-migration down and the module is not finding the script tagged as down:

exports.down = function (connection) {
  console.log('Dropping app tables');
  return Promise.all([
    r.tableDrop('apps').run(connection),
  ]);
};
JohanObrink commented 8 years ago

That has been tested... do you have a repro?

amir-rahnama commented 8 years ago

Yeah the API project. I actually tried it with --all flag (and -all) none of which worked :stuck_out_tongue:

amir-rahnama commented 8 years ago

Actually the problem is that after migration down is ran, it removes the table without checking for success of the down command:

➜  api git:(feature/create_token) ✗ rethink-migrate down
[rethink-migrate] Connecting to database
Creating a pool connected to rethinkdb:28015
[rethink-migrate] Connected
[rethink-migrate]  ↓ down ↓  20151125145853 user
[rethink-migrate] Migration successful
ReqlOpFailedError: Table `foo.bar` already exists in:
r.tableCreate("user"{
^^^^^^^^^^^^^^^^^^^^^
    primaryKey: "userId"
    ^^^^^^^^^^^^^^^^^^^^
})
^^

    at Connection._processResponse (/Users/ara/dev/iteam/api/node_modules/rethinkdbdash/lib/connection.js:229:19)
    at Socket.<anonymous> (/Users/ara/dev/iteam/api/node_modules/rethinkdbdash/lib/connection.js:150:14)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at readableAddChunk (_stream_readable.js:146:16)
    at Socket.Readable.push (_stream_readable.js:110:10)
    at TCP.onread (net.js:523:20)```
JohanObrink commented 8 years ago

Could this be related to #5 ? Right now, all migrations get logged in the db after everything completes. This means that a failing down may result in a corrupt state. I'll try to fix that as soon as possible.