db-migrate / db-migrate/db-migrate-base

db.insert with a callback does not work

Open
#23 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7
Forks
16
PR merge metrics
No merged PRs in 30d

Description

It appears that db.insert does not work with a callback. The code involved is here: https://github.com/db-migrate/db-migrate-base/blob/master/index.js#L453

We never reassign the `callback` variable to `arguments[3]`, so the callback is never called and the migration hangs.

It looks like at one point we did reassign the callback, but took that out in this commit: https://github.com/db-migrate/db-migrate-base/commit/81603379575ac66b581be08fea791fe5ca876b06#diff-168726dbe96b3ce427e7fedce31bb0bc

A workaround is to convert to using the promise API.

Instead of

```js
exports.up = function (db, callback) {
db.insert('tablename', [ col1 ] , [ val1 ], callback);
};
```

do

```js
exports.up = function (db) {
return db.insert('tablename', [ col1 ], [ val1 ]);
};
```

---
Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/93692324-db-insert-with-a-callback-does-not-work?utm_campaign=plugin&utm_content=tracker%2F11792942&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F11792942&utm_medium=issues&utm_source=github).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.