@grouparoo/core
Version:
The Grouparoo Core
45 lines (44 loc) • 1.69 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tables = [
"apiKeys",
"apps",
"destinations",
"groups",
"permissions",
"profilePropertyRules",
"sources",
"schedules",
"settings",
"teams",
"teamMembers",
];
exports.default = {
up: async (queryInterface, DataTypes) => {
for (const i in tables) {
const table = tables[i];
await queryInterface.changeColumn(table, "locked", {
type: DataTypes.STRING(191),
defaultValue: null,
allowNull: true,
});
if (table !== "teams") {
await queryInterface.sequelize.query(`UPDATE "${table}" SET locked='config:code' WHERE (locked = '1' OR locked = 'true')`);
}
else {
await queryInterface.sequelize.query(`UPDATE "${table}" SET locked='team:initialize' WHERE (locked = '1' OR locked = 'true') AND name = 'Administrators' AND "permissionAllWrite" = true AND "permissionAllRead" = true`);
await queryInterface.sequelize.query(`UPDATE "${table}" SET locked='config:code' WHERE (locked = '1' OR locked = 'true') AND name != 'Administrators'`);
}
await queryInterface.sequelize.query(`UPDATE "${table}" SET locked=NULL WHERE (locked = '0' OR locked = 'false')`);
}
},
down: async (queryInterface, DataTypes) => {
for (const i in tables) {
await queryInterface.changeColumn(tables[i], "locked", {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false,
});
}
},
};