diff options
author | BoHong Li | 2017-03-28 15:25:36 +0800 |
---|---|---|
committer | BoHong Li | 2017-03-28 15:28:33 +0800 |
commit | e46874d04a4974ddb655962b6da8afb2928bc991 (patch) | |
tree | 3fd13e29ae3520bdb6a2e5ec061aca1094047d7c /lib/migrations | |
parent | e26bb0503f962e1ee56dfa138b43af4653065812 (diff) |
fix: Other dialect duplicated add index problem
Detect is using SQLite to add index
Diffstat (limited to 'lib/migrations')
-rw-r--r-- | lib/migrations/20150915153700-change-notes-title-to-text.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/migrations/20150915153700-change-notes-title-to-text.js b/lib/migrations/20150915153700-change-notes-title-to-text.js index 2b3a82bf..9d00f15f 100644 --- a/lib/migrations/20150915153700-change-notes-title-to-text.js +++ b/lib/migrations/20150915153700-change-notes-title-to-text.js @@ -1,11 +1,14 @@ 'use strict' +const isSQLite = require('../utils').isSQLite 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']) + if (isSQLite(queryInterface.sequelize)) { + // manual added index will be removed in sqlite + return queryInterface.addIndex('Notes', ['shortid']) + } }) }, @@ -13,7 +16,10 @@ module.exports = { return queryInterface.changeColumn('Notes', 'title', { type: Sequelize.STRING }).then(function () { - return queryInterface.addIndex('Notes', ['shortid']) + if (isSQLite(queryInterface.sequelize)) { + // manual added index will be removed in sqlite + return queryInterface.addIndex('Notes', ['shortid']) + } }) } } |