不要怂,就是干,撸起袖子干!

Commit c8676789 by Sascha Depold

Merge pull request #181 from grn/master

Fix #162
2 parents d896c77a 76a14ab4
Showing with 12 additions and 12 deletions
...@@ -10,8 +10,11 @@ module.exports = (function() { ...@@ -10,8 +10,11 @@ module.exports = (function() {
this.migrator = migrator this.migrator = migrator
this.path = path this.path = path
this.filename = Utils._.last(this.path.split('/')) this.filename = Utils._.last(this.path.split('/'))
this.migrationId = parseInt(this.filename.match(/(.*)-.*/)[1])
this.date = Migration.stringToDate(this.filename) var parsed = Migration.parseFilename(this.filename)
this.migrationId = parsed.id
this.date = parsed.date;
this.queryInterface = this.migrator.queryInterface this.queryInterface = this.migrator.queryInterface
this.undoneMethods = 0 this.undoneMethods = 0
} }
...@@ -20,20 +23,17 @@ module.exports = (function() { ...@@ -20,20 +23,17 @@ module.exports = (function() {
// static ///// // static /////
/////////////// ///////////////
Migration.getFormattedDateString = function(s) { Migration.parseFilename = function(s) {
var result = null var matches = s.match(/^((\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2}))[-_].+/)
try { if(matches === null) {
result = s.match(/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/).slice(1, 6).join('-') throw new Error(s + ' is not a valid migration name! Use YYYYMMDDHHmmss-migration-name format.')
} catch(e) {
throw new Error(s + ' is no valid migration timestamp format! Use YYYYMMDDHHmmss!')
} }
return result return {
id: parseInt(matches[1]),
date: moment(matches.slice(2, 8).join('-'), 'YYYYMMDDHHmmss')
} }
Migration.stringToDate = function(s) {
return moment(Migration.getFormattedDateString(s), "YYYYMMDDHHmmss")
} }
Migration.migrationHasInterfaceCalls = function(func) { Migration.migrationHasInterfaceCalls = function(func) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!