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

32 lines
1.6 KiB
JavaScript

'use strict';
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 },
audience: { type: Sequelize.ENUM('admin', 'user', 'both'), allowNull: false },
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 },
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', ['audience']);
await queryInterface.addIndex('notification_broadcasts', ['deletedAt']);
},
async down(queryInterface) {
await queryInterface.dropTable('notification_broadcasts');
},
};