Files
starr-philproperties/database/migrations/20260711000002-recategorize-advertisement-placements.js
T
kennethobsequio ea3e82e54c added
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-07-12 12:39:17 +08:00

38 lines
1.5 KiB
JavaScript

'use strict';
// Re-categorizes advertisement placements: Hero stays on Dashboard, Banner
// consolidates onto Tier Plans + Course Details. Popup (dashboard.popup) and
// Sidebar (course_details.sidebar) are retired as formats, and the Courses
// list banner (course_list.banner) is dropped along with them since the new
// registry only offers Dashboard / Tier Plans / Course Details.
//
// Existing rows on a retired placement are archived (soft-deleted) rather
// than deleted outright — they still show up in Archived Advertisements for
// an admin to review/permanently delete if desired.
const RETIRED_PLACEMENTS = ['dashboard.popup', 'course_list.banner', 'course_details.sidebar'];
module.exports = {
async up(queryInterface) {
await queryInterface.sequelize.query(`
UPDATE advertisements SET placement = 'tier_plans.banner' WHERE placement = 'plans.banner'
`);
await queryInterface.sequelize.query(`
UPDATE advertisements
SET "deletedAt" = NOW()
WHERE placement IN (:retired) AND "deletedAt" IS NULL
`, {
replacements: { retired: RETIRED_PLACEMENTS },
});
},
async down(queryInterface) {
await queryInterface.sequelize.query(`
UPDATE advertisements SET placement = 'plans.banner' WHERE placement = 'tier_plans.banner'
`);
// Retired-placement rows that were auto-archived by `up` are intentionally
// left archived — there's no reliable way to distinguish them from ads an
// admin archived manually in the meantime.
},
};