This repository was archived by the owner on Oct 1, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -185,22 +185,31 @@ exports.revert = revert
185
185
186
186
/**
187
187
* Function checks if all migrations in given range supports reversion.
188
+ * fromVersion > toVersion
188
189
*
189
190
* @param {array } migrations
190
191
* @param {int } fromVersion
191
192
* @param {int } toVersion
192
193
* @returns {object }
193
194
*/
194
195
function verifyReversibility ( migrations , fromVersion , toVersion ) {
196
+ let migrationCounter = 0
195
197
for ( let migration of migrations ) {
196
198
if ( migration . version > fromVersion ) {
197
199
break
198
200
}
199
201
200
- if ( migration . version >= toVersion && ! migration . reversible ) {
201
- return { reversible : false , version : migration . version }
202
+ if ( migration . version >= toVersion ) {
203
+ migrationCounter ++
204
+
205
+ if ( ! migration . reversible )
206
+ return { reversible : false , version : migration . version }
202
207
}
203
208
}
204
209
205
- return { reversible : true , version : undefined }
210
+ if ( migrationCounter !== ( fromVersion - toVersion ) ) {
211
+ throw new Error ( 'There are missing migration to perform the reversion!' )
212
+ }
213
+
214
+ return { reversible : true , version : undefined }
206
215
}
You can’t perform that action at this time.
0 commit comments