From e26bb0503f962e1ee56dfa138b43af4653065812 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Tue, 28 Mar 2017 15:16:09 +0800 Subject: fix: Support SQlite Move 'unique' constraint to another statement (SQLite don't support set unique when addColumn) --- lib/migrations/20160420180355-note-add-alias.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/migrations/20160420180355-note-add-alias.js') 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']) + }) } } -- cgit v1.2.3