Files
starr-philproperties/database/migrations/20260702000004-add-placement-to-advertisements.js
T
kennethobsequio 1d12f04967 new commits
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-07-03 16:20:58 +08:00

29 lines
1.1 KiB
JavaScript

'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('advertisements', 'placement', {
type: Sequelize.STRING(100),
allowNull: true,
});
await queryInterface.addIndex('advertisements', ['placement']);
// Backfill the only two placements that were actually wired up before this
// migration (Dashboard hero + popup). Any existing banner/sidebar rows are
// left with placement = NULL — dev data, an admin reassigns them via the
// edit form once the new Page/Position picker ships.
await queryInterface.sequelize.query(`
UPDATE advertisements SET placement = 'dashboard.hero' WHERE type = 'hero' AND placement IS NULL
`);
await queryInterface.sequelize.query(`
UPDATE advertisements SET placement = 'dashboard.popup' WHERE type = 'popup' AND placement IS NULL
`);
},
async down(queryInterface) {
await queryInterface.removeIndex('advertisements', ['placement']).catch(() => {});
await queryInterface.removeColumn('advertisements', 'placement');
},
};