Skip to content
This repository was archived by the owner on Aug 17, 2022. It is now read-only.

Commit 8e7e785

Browse files
authored
Merge pull request #2 from rivalgames/master
Fix invalid order of fixtures due to filename
2 parents ebca3d3 + 7720cca commit 8e7e785

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

lib/migrate.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,13 +811,30 @@ module.exports = {
811811
`;
812812

813813
name = name.replace(' ', '_');
814-
let filename = path.join(migrationsDir, revision + ((name != '') ? `-${name}` : '') + '.js');
814+
let filename = path.join(migrationsDir, getCurrentYYYYMMDDHHmms() + '-' + revision + ((name != '') ? `-${name}` : '') + '.js');
815815

816816
fs.writeFileSync(filename, template);
817817

818818
return {filename, info};
819819
};
820820

821+
const format = function (i) {
822+
return parseInt(i, 10) < 10 ? '0' + i : i;
823+
};
824+
825+
const getCurrentYYYYMMDDHHmms = function () {
826+
const date = new Date();
827+
return [
828+
date.getUTCFullYear(),
829+
format(date.getUTCMonth() + 1),
830+
format(date.getUTCDate()),
831+
format(date.getUTCHours()),
832+
format(date.getUTCMinutes()),
833+
format(date.getUTCSeconds())
834+
].join('');
835+
};
836+
837+
821838
const executeMigration = function(queryInterface, filename, pos, cb)
822839
{
823840
let mig = require(filename);

0 commit comments

Comments
 (0)