feat: Add read-only collections (#1991)

closes #1017
This commit is contained in:
Tom Moor
2021-03-30 21:02:08 -07:00
committed by GitHub
parent d7acf616cf
commit 7e1b07ef98
50 changed files with 940 additions and 558 deletions

View File

@@ -0,0 +1,38 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("collections", "permission", {
type: Sequelize.STRING,
defaultValue: null,
allowNull: true,
validate: {
isIn: [["read", "read_write"]],
},
});
await queryInterface.sequelize.query(`
UPDATE collections
SET "permission" = 'read_write'
WHERE "private" = false
`);
await queryInterface.removeColumn("collections", "private");
},
down: async (queryInterface, Sequelize) => {
await queryInterface.addColumn("collections", "private", {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: false
});
await queryInterface.sequelize.query(`
UPDATE collections
SET "private" = true
WHERE "permission" IS NULL
`);
await queryInterface.removeColumn("collections", "permission");
}
};