mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -0,0 +1,28 @@
|
||||
'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');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user