diff options
Diffstat (limited to '')
-rw-r--r-- | lib/migrations/20150702001020-update-to-0_3_1.js | 16 | ||||
-rw-r--r-- | lib/migrations/20150915153700-change-notes-title-to-text.js | 5 | ||||
-rw-r--r-- | lib/migrations/20160420180355-note-add-alias.js | 11 |
3 files changed, 25 insertions, 7 deletions
diff --git a/lib/migrations/20150702001020-update-to-0_3_1.js b/lib/migrations/20150702001020-update-to-0_3_1.js index a3163d74..40d9c97a 100644 --- a/lib/migrations/20150702001020-update-to-0_3_1.js +++ b/lib/migrations/20150702001020-update-to-0_3_1.js @@ -3,17 +3,22 @@ module.exports = { up: function (queryInterface, Sequelize) { return queryInterface.addColumn('Notes', 'shortid', { type: Sequelize.STRING, - unique: true, + defaultValue: '0000000000', allowNull: false }).then(function () { + return queryInterface.addIndex('Notes', ['shortid'], { + indicesType: 'UNIQUE' + }) + }).then(function () { return queryInterface.addColumn('Notes', 'permission', { type: Sequelize.STRING, - allowNull: false, - defaultValue: 0 + defaultValue: 'private', + allowNull: false }) }).then(function () { return queryInterface.addColumn('Notes', 'viewcount', { - type: Sequelize.INTEGER + type: Sequelize.INTEGER, + defaultValue: 0 }) }) }, @@ -24,6 +29,9 @@ module.exports = { return queryInterface.removeColumn('Notes', 'permission') }) .then(function () { + return queryInterface.removeIndex('Notes', ['shortid']) + }) + .then(function () { return queryInterface.removeColumn('Notes', 'shortid') }) } diff --git a/lib/migrations/20150915153700-change-notes-title-to-text.js b/lib/migrations/20150915153700-change-notes-title-to-text.js index 6f7307d1..2b3a82bf 100644 --- a/lib/migrations/20150915153700-change-notes-title-to-text.js +++ b/lib/migrations/20150915153700-change-notes-title-to-text.js @@ -3,12 +3,17 @@ module.exports = { up: function (queryInterface, Sequelize) { return queryInterface.changeColumn('Notes', 'title', { type: Sequelize.TEXT + }).then(function () { + // manual added index will be removed in sqlite + return queryInterface.addIndex('Notes', ['shortid']) }) }, down: function (queryInterface, Sequelize) { return queryInterface.changeColumn('Notes', 'title', { type: Sequelize.STRING + }).then(function () { + return queryInterface.addIndex('Notes', ['shortid']) }) } } diff --git a/lib/migrations/20160420180355-note-add-alias.js b/lib/migrations/20160420180355-note-add-alias.js index 2c3e453b..a043cd5c 100644 --- a/lib/migrations/20160420180355-note-add-alias.js +++ b/lib/migrations/20160420180355-note-add-alias.js @@ -2,12 +2,17 @@ module.exports = { up: function (queryInterface, Sequelize) { return queryInterface.addColumn('Notes', 'alias', { - type: Sequelize.STRING, - unique: true + type: Sequelize.STRING + }).then(function () { + return queryInterface.addIndex('Notes', ['alias'], { + indicesType: 'UNIQUE' + }) }) }, down: function (queryInterface, Sequelize) { - return queryInterface.removeColumn('Notes', 'alias') + return queryInterface.removeColumn('Notes', 'alias').then(function () { + return queryInterface.removeIndex('Notes', ['alias']) + }) } } |