From 2288082946d64a9d56d9d265cd6cda2fa51aa31b Mon Sep 17 00:00:00 2001 From: Saumya Pandey Date: Thu, 18 Feb 2021 17:35:56 +0530 Subject: [PATCH] Add index column in collections --- .../20210218111237-add-collection-index.js | 14 ++++++++++++++ server/models/Collection.js | 4 ++++ server/presenters/collection.js | 1 + 3 files changed, 19 insertions(+) create mode 100644 server/migrations/20210218111237-add-collection-index.js diff --git a/server/migrations/20210218111237-add-collection-index.js b/server/migrations/20210218111237-add-collection-index.js new file mode 100644 index 0000000000..4ce3246f69 --- /dev/null +++ b/server/migrations/20210218111237-add-collection-index.js @@ -0,0 +1,14 @@ +"use strict"; + +module.exports = { + up: async (queryInterface, Sequelize) => { + await queryInterface.addColumn("collections", "index", { + type: Sequelize.TEXT, + defaultValue: null, + }); + }, + + down: async (queryInterface, Sequelize) => { + await queryInterface.removeColumn("collections", "index"); + }, +}; diff --git a/server/models/Collection.js b/server/models/Collection.js index e2e41f8c75..1f6614b583 100644 --- a/server/models/Collection.js +++ b/server/models/Collection.js @@ -21,6 +21,10 @@ const Collection = sequelize.define( description: DataTypes.STRING, icon: DataTypes.STRING, color: DataTypes.STRING, + index: { + type: DataTypes.STRING, + defaultValue: null, + }, private: DataTypes.BOOLEAN, maintainerApprovalRequired: DataTypes.BOOLEAN, documentStructure: DataTypes.JSONB, diff --git a/server/presenters/collection.js b/server/presenters/collection.js index b877e9c577..5fbbf62817 100644 --- a/server/presenters/collection.js +++ b/server/presenters/collection.js @@ -28,6 +28,7 @@ export default function present(collection: Collection) { description: collection.description, sort: collection.sort, icon: collection.icon, + index: collection.index, color: collection.color || "#4E5C6E", private: collection.private, sharing: collection.sharing,