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

Commit 0457a47e by sdepold

binary can now create migration skeletons

1 parent e8bc41a5
Showing with 23 additions and 0 deletions
...@@ -4,6 +4,7 @@ const path = require("path") ...@@ -4,6 +4,7 @@ const path = require("path")
, fs = require("fs") , fs = require("fs")
, program = require("commander") , program = require("commander")
, Sequelize = require(__dirname + '/../index') , Sequelize = require(__dirname + '/../index')
, moment = require("moment")
, _ = Sequelize.Utils._ , _ = Sequelize.Utils._
var configPath = process.cwd() + '/config' var configPath = process.cwd() + '/config'
...@@ -60,6 +61,7 @@ program ...@@ -60,6 +61,7 @@ program
.option('-m, --migrate', 'Runs undone migrations') .option('-m, --migrate', 'Runs undone migrations')
.option('-u, --undo', 'Redo the last migration.') .option('-u, --undo', 'Redo the last migration.')
.option('-f, --force', 'Forces the action to be done.') .option('-f, --force', 'Forces the action to be done.')
.option('-c, --create-migration [migration-name]', 'Create a new migration skeleton file.')
.parse(process.argv) .parse(process.argv)
if(program.migrate) { if(program.migrate) {
...@@ -110,6 +112,26 @@ if(program.migrate) { ...@@ -110,6 +112,26 @@ if(program.migrate) {
} }
createMigrationsFolder(program.force) createMigrationsFolder(program.force)
} else if(program.createMigration) {
createMigrationsFolder()
var migrationName = [
moment().format('YYYYMMDDHHmmss'),
(typeof program.createMigration == 'string') ? program.createMigration : 'unnamed-migration'
].join('-') + '.js'
var migrationContent = [
"module.exports = {",
" up: function(migration, DataTypes) {",
" // add altering commands here",
" },",
" down: function(migration) {",
" // add reverting commands here",
" }",
"}"
].join('\n')
fs.writeFileSync(migrationsPath + '/' + migrationName, migrationContent)
} else { } else {
console.log('Please define any params!') console.log('Please define any params!')
} }
# v1.4.1 # # v1.4.1 #
- [DEPRECATION] Added deprecation warning for node < v0.6. - [DEPRECATION] Added deprecation warning for node < v0.6.
- [FEATURE] added selective saving of instances (thanks to kioopi) - [FEATURE] added selective saving of instances (thanks to kioopi)
- [FEATURE] added command to binary for creating a migration skeleton with current timestamp
# v1.4.0 # # v1.4.0 #
- [BUG] fixed booleans in sqlite (thanks to alexstrat) - [BUG] fixed booleans in sqlite (thanks to alexstrat)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!