'use strict'; // `target_type` was originally `audience` (ENUM admin/user/both), renamed and // extended with task_list/course/tier_plan via ALTER TYPE ADD VALUE on the // live type `notification_broadcast_audience` (20260702000002). module.exports = { async up(queryInterface, Sequelize) { await queryInterface.createTable('notification_broadcasts', { broadcast_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true }, uuid: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, allowNull: false, unique: true }, title: { type: Sequelize.STRING(255), allowNull: false }, message: { type: Sequelize.TEXT, allowNull: false }, target_type: { type: Sequelize.ENUM('admin', 'user', 'both', 'task_list', 'course', 'tier_plan'), allowNull: false }, target_id: { type: Sequelize.STRING(64), allowNull: true }, status: { type: Sequelize.ENUM('draft', 'sent', 'archived'), allowNull: false, defaultValue: 'draft' }, sent_at: { type: Sequelize.DATE, allowNull: true }, recipient_count: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 }, link_url: { type: Sequelize.STRING(2048), allowNull: true }, link_label: { type: Sequelize.STRING(60), allowNull: true }, color: { type: Sequelize.STRING(20), allowNull: false, defaultValue: 'indigo' }, show_in_sticky: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: false }, show_in_notifications: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: true }, start_date: { type: Sequelize.DATE, allowNull: true }, end_date: { type: Sequelize.DATE, allowNull: true }, createdBy: { type: Sequelize.BIGINT, allowNull: true }, updatedBy: { type: Sequelize.BIGINT, allowNull: true }, deletedBy: { type: Sequelize.BIGINT, allowNull: true }, createdAt: { type: Sequelize.DATE, allowNull: false }, updatedAt: { type: Sequelize.DATE, allowNull: false }, deletedAt: { type: Sequelize.DATE, allowNull: true }, }); await queryInterface.addIndex('notification_broadcasts', ['uuid']); await queryInterface.addIndex('notification_broadcasts', ['status']); await queryInterface.addIndex('notification_broadcasts', ['target_type']); await queryInterface.addIndex('notification_broadcasts', ['deletedAt']); }, async down(queryInterface) { await queryInterface.dropTable('notification_broadcasts'); }, };