This repository was archived by the owner on Oct 1, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Expand file tree Collapse file tree 2 files changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ exports.errors = errors
14
14
15
15
/**
16
16
* Returns the version of latest migration.
17
+ * If no migrations are present returns 0.
17
18
*
18
19
* @param {array? } migrations - Array of migrations to consider. If undefined, the bundled migrations are used. Mainly for testing purpose.
19
20
* @returns {int }
@@ -22,7 +23,7 @@ function getLatestMigrationVersion (migrations) {
22
23
migrations = migrations || defaultMigrations
23
24
24
25
if ( ! Array . isArray ( migrations ) || migrations . length === 0 ) {
25
- throw new errors . InvalidValueError ( 'Migrations must be non-empty array!' )
26
+ return 0
26
27
}
27
28
28
29
return migrations [ migrations . length - 1 ] . version
Original file line number Diff line number Diff line change @@ -80,10 +80,7 @@ describe('index.js', () => {
80
80
const migrationsMock = createMigrations ( )
81
81
82
82
expect ( migrator . getLatestMigrationVersion ( migrationsMock ) ) . to . equal ( 4 )
83
-
84
- expect (
85
- ( ) => migrator . getLatestMigrationVersion ( [ ] )
86
- ) . to . throw ( errors . InvalidValueError ) . with . property ( 'code' , errors . InvalidValueError . code )
83
+ expect ( migrator . getLatestMigrationVersion ( [ ] ) ) . to . equal ( 0 )
87
84
} )
88
85
89
86
describe ( 'revert' , ( ) => {
You can’t perform that action at this time.
0 commit comments