Skip to content

Commit

Permalink
fix globalconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Nov 16, 2016
1 parent a73a4aa commit eb2773f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion db/model/globalconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const constants = require('../constants');

const assoc = {};

module.exports = function user(seq, dataTypes) {
module.exports = function globalconfig(seq, dataTypes) {
const GlobalConfig = seq.define('GlobalConfig', {
id: {
type: dataTypes.UUID,
Expand Down
40 changes: 40 additions & 0 deletions migrations/20161115215050-fixglobalconfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2016, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or
* https://opensource.org/licenses/BSD-3-Clause
*/

/**
* Because a deployment may have a poorly-defined GlobalConfigs table at this
* time, this migration tests for the existence of the "createdAt" field and
* only drops the table if that field does not exist. After this migration,
* when the server starts up and index.js calls sync on all the models, the
* GlobalConfigs table will be created properly.
*/
'use strict';
const tableName = 'GlobalConfigs';

module.exports = {
up: function (queryInterface, Sequelize) {
return queryInterface.describeTable(tableName)
.then((attributes) => {
return 'createdAt' in attributes;
})
.then((hasCreatedAtField) => {
if (!hasCreatedAtField) {
return queryInterface.dropTable(tableName);
}

return true;
});
},

down: function (queryInterface, Sequelize) {
/*
* There is no "down" function defined in this migration, i.e. there is
* nothing to undo here to restore the database to a desired state.
*/
}
};

0 comments on commit eb2773f

Please sign in to comment.