From 6f14822413eeb43aae1298163699f87bc1ce11e7 Mon Sep 17 00:00:00 2001 From: BoHong Li Date: Mon, 27 Mar 2017 19:23:00 +0800 Subject: fix: Add missing migration --- lib/migrations/20160420180355-note-add-alias.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 lib/migrations/20160420180355-note-add-alias.js (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 new file mode 100644 index 00000000..2c3e453b --- /dev/null +++ b/lib/migrations/20160420180355-note-add-alias.js @@ -0,0 +1,13 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.addColumn('Notes', 'alias', { + type: Sequelize.STRING, + unique: true + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.removeColumn('Notes', 'alias') + } +} -- cgit v1.2.3 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