mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
async up(queryInterface, Sequelize) {
|
||||
// CockroachDB: add enum values in place, then rename the column.
|
||||
// Type is named 'notification_broadcast_audience' (matches the explicit CREATE TYPE
|
||||
// used when this table was first created — not Sequelize's default enum_<table>_<col> name).
|
||||
await queryInterface.sequelize.query(`ALTER TYPE public.notification_broadcast_audience ADD VALUE IF NOT EXISTS 'task_list'`);
|
||||
await queryInterface.sequelize.query(`ALTER TYPE public.notification_broadcast_audience ADD VALUE IF NOT EXISTS 'course'`);
|
||||
await queryInterface.sequelize.query(`ALTER TYPE public.notification_broadcast_audience ADD VALUE IF NOT EXISTS 'tier_plan'`);
|
||||
|
||||
await queryInterface.renameColumn('notification_broadcasts', 'audience', 'target_type');
|
||||
|
||||
await queryInterface.addColumn('notification_broadcasts', 'target_id', {
|
||||
type: Sequelize.STRING(64),
|
||||
allowNull: true,
|
||||
});
|
||||
|
||||
await queryInterface.removeIndex('notification_broadcasts', ['audience']).catch(() => {});
|
||||
await queryInterface.addIndex('notification_broadcasts', ['target_type']);
|
||||
},
|
||||
|
||||
async down(queryInterface) {
|
||||
await queryInterface.removeColumn('notification_broadcasts', 'target_id');
|
||||
await queryInterface.renameColumn('notification_broadcasts', 'target_type', 'audience');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user