Files
starr-philproperties/database/migrations/20260101000024-create-advertisements.js
T
kennethobsequio 439bb33f77 ready to test
Testing

Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
2026-06-22 10:06:58 +08:00

41 lines
2.3 KiB
JavaScript

'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('advertisements', {
advertisement_id: { type: Sequelize.BIGINT, primaryKey: true, autoIncrement: true },
uuid: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, allowNull: false, unique: true },
type: { type: Sequelize.ENUM('hero', 'banner', 'popup', 'sidebar'), allowNull: false },
status: { type: Sequelize.ENUM('draft', 'active', 'scheduled', 'expired', 'archived'), allowNull: false, defaultValue: 'draft' },
badge_label: { type: Sequelize.STRING(100) },
headline: { type: Sequelize.STRING(255) },
description: { type: Sequelize.TEXT },
image_url: { type: Sequelize.STRING(512) },
image_asset_id: { type: Sequelize.BIGINT, allowNull: true, references: { model: 'assets', key: 'asset_id' }, onDelete: 'SET NULL' },
ctas: { type: Sequelize.JSONB, allowNull: false, defaultValue: [] },
start_date: { type: Sequelize.DATE },
end_date: { type: Sequelize.DATE },
order: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0 },
is_active: { type: Sequelize.BOOLEAN, allowNull: false, defaultValue: true },
size: { type: Sequelize.ENUM('sm', 'md', 'lg'), allowNull: true },
click_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('advertisements', ['uuid']);
await queryInterface.addIndex('advertisements', ['type']);
await queryInterface.addIndex('advertisements', ['status']);
await queryInterface.addIndex('advertisements', ['is_active']);
await queryInterface.addIndex('advertisements', ['deletedAt']);
},
async down(queryInterface) {
await queryInterface.dropTable('advertisements');
},
};