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

Commit 22ed6a0

Browse files
authored
use timestamp for filename
1 parent 0c3b385 commit 22ed6a0

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

lib/migrate.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,13 +810,26 @@ module.exports = {
810810
`;
811811

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

815815
fs.writeFileSync(filename, template);
816816

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

820+
const getCurrentYYYYMMDDHHmms = function () {
821+
const date = new Date();
822+
return [
823+
date.getUTCFullYear(),
824+
format(date.getUTCMonth() + 1),
825+
format(date.getUTCDate()),
826+
format(date.getUTCHours()),
827+
format(date.getUTCMinutes()),
828+
format(date.getUTCSeconds())
829+
].join('');
830+
}
831+
832+
820833
const executeMigration = function(queryInterface, filename, pos, cb)
821834
{
822835
let mig = require(filename);

0 commit comments

Comments
 (0)