Add icon column to document (#7066)
* Add icon column to document * Backfill columns --------- Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
79
server/migrations/20240617151506-add-icon-to-document.js
Normal file
79
server/migrations/20240617151506-add-icon-to-document.js
Normal file
@@ -0,0 +1,79 @@
|
||||
"use strict";
|
||||
|
||||
/** @type {import('sequelize-cli').Migration} */
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
await queryInterface.sequelize.transaction(async transaction => {
|
||||
await queryInterface.addColumn(
|
||||
"documents",
|
||||
"icon",
|
||||
{
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
{
|
||||
transaction,
|
||||
}
|
||||
);
|
||||
await queryInterface.addColumn(
|
||||
"revisions",
|
||||
"icon",
|
||||
{
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
{
|
||||
transaction,
|
||||
}
|
||||
);
|
||||
await queryInterface.addColumn(
|
||||
"documents",
|
||||
"color",
|
||||
{
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
await queryInterface.addColumn(
|
||||
"revisions",
|
||||
"color",
|
||||
{
|
||||
type: Sequelize.STRING,
|
||||
allowNull: true,
|
||||
},
|
||||
{ transaction }
|
||||
);
|
||||
});
|
||||
|
||||
if (process.env.DEPLOYMENT === "hosted") {
|
||||
return;
|
||||
}
|
||||
|
||||
await queryInterface.sequelize.transaction(async (transaction) => {
|
||||
await queryInterface.sequelize.query(
|
||||
`UPDATE documents SET icon = emoji`,
|
||||
{
|
||||
transaction,
|
||||
type: queryInterface.sequelize.QueryTypes.UPDATE,
|
||||
}
|
||||
);
|
||||
await queryInterface.sequelize.query(
|
||||
`UPDATE revisions SET icon = emoji`,
|
||||
{
|
||||
transaction,
|
||||
type: queryInterface.sequelize.QueryTypes.UPDATE,
|
||||
}
|
||||
);
|
||||
});
|
||||
},
|
||||
|
||||
async down(queryInterface, Sequelize) {
|
||||
await queryInterface.sequelize.transaction(async transaction => {
|
||||
await queryInterface.removeColumn("documents", "icon", { transaction });
|
||||
await queryInterface.removeColumn("revisions", "icon", { transaction });
|
||||
await queryInterface.removeColumn("documents", "color", { transaction });
|
||||
await queryInterface.removeColumn("revisions", "color", { transaction });
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user