From 37de2f045629f0219c4d2d479850caa33307d04b Mon Sep 17 00:00:00 2001 From: Anton Vynogradenko Date: Sun, 17 Feb 2019 17:12:57 -0800 Subject: [PATCH] add "removeIndex" before "addIndex" This makes index creation operations idempotent. Migrations that create indexes now can be run multiple times without errors. --- lib/migrate.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/migrate.js b/lib/migrate.js index 4ed5adc..836a24b 100644 --- a/lib/migrate.js +++ b/lib/migrate.js @@ -306,6 +306,12 @@ const parseDifference = function(previousState, currentState) if (df.rhs.indexes) for(let _i in df.rhs.indexes) { + actions.push(_.extend({ + actionType: 'removeIndex', + tableName: tableName, + depends: [ tableName ] + }, _.clone(df.rhs.indexes[_i]))); + actions.push(_.extend({ actionType: 'addIndex', tableName: tableName,