diff options
author | Raccoon | 2017-03-28 16:48:30 +0800 |
---|---|---|
committer | GitHub | 2017-03-28 16:48:30 +0800 |
commit | 0b4dac74ed8c0da66c340add45ce78a067c69ee9 (patch) | |
tree | 3fd13e29ae3520bdb6a2e5ec061aca1094047d7c | |
parent | b2985085d011cad374c76ae75f548fdefb15c258 (diff) | |
parent | e46874d04a4974ddb655962b6da8afb2928bc991 (diff) |
Merge pull request #406 from hackmdio/feature/add_missing_migration
fix: Add missing migration
Diffstat (limited to '')
-rw-r--r-- | lib/migrations/20150504155329-create-users.js | 24 | ||||
-rw-r--r-- | lib/migrations/20150508114741-create-notes.js | 21 | ||||
-rw-r--r-- | lib/migrations/20150515125813-create-temp.js | 18 | ||||
-rw-r--r-- | lib/migrations/20150702001020-update-to-0_3_1.js | 38 | ||||
-rw-r--r-- | lib/migrations/20150915153700-change-notes-title-to-text.js | 25 | ||||
-rw-r--r-- | lib/migrations/20160112220142-note-add-lastchange.js | 19 | ||||
-rw-r--r-- | lib/migrations/20160420180355-note-add-alias.js | 18 | ||||
-rw-r--r-- | lib/utils.js | 5 |
8 files changed, 168 insertions, 0 deletions
diff --git a/lib/migrations/20150504155329-create-users.js b/lib/migrations/20150504155329-create-users.js new file mode 100644 index 00000000..51e6b29c --- /dev/null +++ b/lib/migrations/20150504155329-create-users.js @@ -0,0 +1,24 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.createTable('Users', { + id: { + type: Sequelize.UUID, + primaryKey: true, + defaultValue: Sequelize.UUIDV4 + }, + profileid: { + type: Sequelize.STRING, + unique: true + }, + profile: Sequelize.TEXT, + history: Sequelize.TEXT, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.dropTable('Users') + } +} diff --git a/lib/migrations/20150508114741-create-notes.js b/lib/migrations/20150508114741-create-notes.js new file mode 100644 index 00000000..660d40a6 --- /dev/null +++ b/lib/migrations/20150508114741-create-notes.js @@ -0,0 +1,21 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.createTable('Notes', { + id: { + type: Sequelize.UUID, + primaryKey: true, + defaultValue: Sequelize.UUIDV4 + }, + ownerId: Sequelize.UUID, + content: Sequelize.TEXT, + title: Sequelize.STRING, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.dropTable('Notes') + } +} diff --git a/lib/migrations/20150515125813-create-temp.js b/lib/migrations/20150515125813-create-temp.js new file mode 100644 index 00000000..ee7b9789 --- /dev/null +++ b/lib/migrations/20150515125813-create-temp.js @@ -0,0 +1,18 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.createTable('Temp', { + id: { + type: Sequelize.STRING, + primaryKey: true + }, + date: Sequelize.TEXT, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.dropTable('Temp') + } +} diff --git a/lib/migrations/20150702001020-update-to-0_3_1.js b/lib/migrations/20150702001020-update-to-0_3_1.js new file mode 100644 index 00000000..40d9c97a --- /dev/null +++ b/lib/migrations/20150702001020-update-to-0_3_1.js @@ -0,0 +1,38 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.addColumn('Notes', 'shortid', { + type: Sequelize.STRING, + defaultValue: '0000000000', + allowNull: false + }).then(function () { + return queryInterface.addIndex('Notes', ['shortid'], { + indicesType: 'UNIQUE' + }) + }).then(function () { + return queryInterface.addColumn('Notes', 'permission', { + type: Sequelize.STRING, + defaultValue: 'private', + allowNull: false + }) + }).then(function () { + return queryInterface.addColumn('Notes', 'viewcount', { + type: Sequelize.INTEGER, + defaultValue: 0 + }) + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.removeColumn('Notes', 'viewcount') + .then(function () { + 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 new file mode 100644 index 00000000..9d00f15f --- /dev/null +++ b/lib/migrations/20150915153700-change-notes-title-to-text.js @@ -0,0 +1,25 @@ +'use strict' +const isSQLite = require('../utils').isSQLite +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.changeColumn('Notes', 'title', { + type: Sequelize.TEXT + }).then(function () { + if (isSQLite(queryInterface.sequelize)) { + // 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 () { + if (isSQLite(queryInterface.sequelize)) { + // manual added index will be removed in sqlite + return queryInterface.addIndex('Notes', ['shortid']) + } + }) + } +} diff --git a/lib/migrations/20160112220142-note-add-lastchange.js b/lib/migrations/20160112220142-note-add-lastchange.js new file mode 100644 index 00000000..b4e111b3 --- /dev/null +++ b/lib/migrations/20160112220142-note-add-lastchange.js @@ -0,0 +1,19 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.addColumn('Notes', 'lastchangeuserId', { + type: Sequelize.UUID + }).then(function () { + return queryInterface.addColumn('Notes', 'lastchangeAt', { + type: Sequelize.DATE + }) + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.removeColumn('Notes', 'lastchangeAt') + .then(function () { + return queryInterface.removeColumn('Notes', 'lastchangeuserId') + }) + } +} diff --git a/lib/migrations/20160420180355-note-add-alias.js b/lib/migrations/20160420180355-note-add-alias.js new file mode 100644 index 00000000..a043cd5c --- /dev/null +++ b/lib/migrations/20160420180355-note-add-alias.js @@ -0,0 +1,18 @@ +'use strict' +module.exports = { + up: function (queryInterface, Sequelize) { + return queryInterface.addColumn('Notes', 'alias', { + type: Sequelize.STRING + }).then(function () { + return queryInterface.addIndex('Notes', ['alias'], { + indicesType: 'UNIQUE' + }) + }) + }, + + down: function (queryInterface, Sequelize) { + return queryInterface.removeColumn('Notes', 'alias').then(function () { + return queryInterface.removeIndex('Notes', ['alias']) + }) + } +} diff --git a/lib/utils.js b/lib/utils.js new file mode 100644 index 00000000..6c36549b --- /dev/null +++ b/lib/utils.js @@ -0,0 +1,5 @@ +'use strict' + +exports.isSQLite = function isSQLite (sequelize) { + return sequelize.options.dialect === 'sqlite' +} |