-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
} | ||
}; |