60 lines
1.5 KiB
JavaScript
60 lines
1.5 KiB
JavaScript
module.exports = {
|
|
async up(queryInterface, Sequelize) {
|
|
const transaction = await queryInterface.sequelize.transaction();
|
|
try {
|
|
await queryInterface.addColumn(
|
|
'organizations',
|
|
'defaultView',
|
|
{
|
|
type: Sequelize.DataTypes.TEXT,
|
|
allowNull: false,
|
|
defaultValue: 'list',
|
|
},
|
|
{ transaction }
|
|
);
|
|
|
|
await queryInterface.changeColumn(
|
|
'organizations',
|
|
'navOrientation',
|
|
{
|
|
type: Sequelize.DataTypes.TEXT,
|
|
allowNull: false,
|
|
defaultValue: 'top',
|
|
},
|
|
{ transaction }
|
|
);
|
|
|
|
await queryInterface.sequelize.query(
|
|
"UPDATE organizations SET \"navOrientation\" = 'top', \"defaultView\" = 'list'",
|
|
{ transaction }
|
|
);
|
|
|
|
await transaction.commit();
|
|
} catch (err) {
|
|
await transaction.rollback();
|
|
throw err;
|
|
}
|
|
},
|
|
|
|
async down(queryInterface, Sequelize) {
|
|
const transaction = await queryInterface.sequelize.transaction();
|
|
try {
|
|
await queryInterface.removeColumn('organizations', 'defaultView', { transaction });
|
|
await queryInterface.changeColumn(
|
|
'organizations',
|
|
'navOrientation',
|
|
{
|
|
type: Sequelize.DataTypes.TEXT,
|
|
allowNull: false,
|
|
defaultValue: 'side',
|
|
},
|
|
{ transaction }
|
|
);
|
|
await transaction.commit();
|
|
} catch (err) {
|
|
await transaction.rollback();
|
|
throw err;
|
|
}
|
|
},
|
|
};
|