Skip to content

Commit ca3fff9

Browse files
committed
add safe guard
Signed-off-by: Tobias Gurtzick <[email protected]>
1 parent fdd28b0 commit ca3fff9

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lib/methods/v2/translatestate.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const Promise = require('bluebird');
22
const State = require('../../state');
33
const Chain = require('../../chain');
44
const Migrate = require('./migrate');
5+
const log = require('db-migrate-shared').log;
56

67
const methods = {
78
createTable: async (driver, [t], internals) => {
@@ -45,6 +46,17 @@ const methods = {
4546
},
4647

4748
addIndex: async (driver, [t, i], internals) => {
49+
if (!internals.modSchema.i[t][i]) {
50+
log.warning(
51+
`There was an attempt to create the index "${i}" in the table "${t}".`
52+
);
53+
log.warning(
54+
`This index did not exist at the time of deleting it. ` +
55+
`This can happen if an index was created by hand and then deleted` +
56+
`by db-migrate. Make sure to recreate it by hand to avoid any problems.`
57+
);
58+
return Promise.resolve();
59+
}
4860
return driver.addIndex(
4961
t,
5062
i,

0 commit comments

Comments
 (0)