From c9a2db70b6eb7eb631259aed72b37287a73b92d4 Mon Sep 17 00:00:00 2001 From: Scimonster Date: Mon, 17 Jun 2019 22:46:49 +0300 Subject: [PATCH] Remove duplicates in migration actions Naive comparison to previous item after it has been sorted Makes generated migration cleaner --- lib/migrate.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/migrate.js b/lib/migrate.js index a41fab8..a02b406 100644 --- a/lib/migrate.js +++ b/lib/migrate.js @@ -575,6 +575,7 @@ const sortActions = function(actions) return 0; }); + // sort dependencies for (let k = 0; k <= actions.length ; k++) for (let i = 0; i < actions.length ; i++) { @@ -606,6 +607,14 @@ const sortActions = function(actions) } } + + // remove duplicate changeColumns + for (let i = 0; i < actions.length ; i++) + { + if (_.isEqual(actions[i], actions[i-1])) { + actions.splice(i, 1); + } + } };