From f9c5490638d9b952db744b761bf30aa2cf614d15 Mon Sep 17 00:00:00 2001 From: Hike Danakian Date: Tue, 16 Jul 2013 02:58:45 -0700 Subject: [PATCH] Added db migration script and directory. --- config/orm.js | 2 +- config/s3.js | 2 +- migrations/.gitkeep | 0 scripts/migrate_db.js | 5 +++++ util.js | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 migrations/.gitkeep create mode 100755 scripts/migrate_db.js diff --git a/config/orm.js b/config/orm.js index a84f1db..3fdf415 100644 --- a/config/orm.js +++ b/config/orm.js @@ -4,7 +4,7 @@ module.exports = function () { util = require('../util'); /* Load Database Configuration */ - var db = util.getEnvConf(DB_FIELDS, { prefix: 'DB_' }); + var db = util.getEnvConfig(DB_FIELDS, { prefix: 'DB_' }); // use sqlite by defaults if no dialect is specified db.dialect = db.dialect || 'sqlite'; diff --git a/config/s3.js b/config/s3.js index 29383d8..9a7f21f 100644 --- a/config/s3.js +++ b/config/s3.js @@ -6,7 +6,7 @@ module.exports = function () { util = require('../util'); /* Load S3 Configuration */ - var s3_conf = util.getEnvConf(S3_FIELDS, { prefix: 'S3_' }), + var s3_conf = util.getEnvConfig(S3_FIELDS, { prefix: 'S3_' }), s3_mode = this.app.get('env') === 'production' ? 'nox' : 'mox'; if (!util.hasFields(s3_conf, ['key', 'secret'])) diff --git a/migrations/.gitkeep b/migrations/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/scripts/migrate_db.js b/scripts/migrate_db.js new file mode 100755 index 0000000..dba17d6 --- /dev/null +++ b/scripts/migrate_db.js @@ -0,0 +1,5 @@ +#!/usr/bin/env node + +var orm = require('../config/orm').call(); +var migrator = orm.sequelize.getMigrator({ path: './migrations' }); +migrator.migrate(); diff --git a/util.js b/util.js index 8864eea..2900092 100644 --- a/util.js +++ b/util.js @@ -23,7 +23,7 @@ module.exports = { hasFields: function (o, fields) { return o && fields.every(function (f) { return o[f] !== undefined }); }, - getEnvConf: function (fields, opts) { + getEnvConfig: function (fields, opts) { var prefix = opts.prefix || '', conf = {}; fields.forEach(function (f) { conf[f] = process.env[(prefix + f).toUpperCase()];