Files
Hotel-Booking/server/src/databases/migrations/20250101000012-create-banners.js
Iliyan Angelov 824eec6190 Hotel Booking
2025-11-16 14:19:13 +02:00

74 lines
1.7 KiB
JavaScript

'use strict';
/** @type {import('sequelize-cli').Migration} */
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('banners', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
title: {
type: Sequelize.STRING(100),
allowNull: false
},
description: {
type: Sequelize.TEXT,
allowNull: true
},
image_url: {
type: Sequelize.STRING(255),
allowNull: false
},
link_url: {
type: Sequelize.STRING(255),
allowNull: true
},
position: {
type: Sequelize.STRING(50),
allowNull: false,
defaultValue: 'home'
},
display_order: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0
},
is_active: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true
},
start_date: {
type: Sequelize.DATE,
allowNull: true
},
end_date: {
type: Sequelize.DATE,
allowNull: true
},
created_at: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP')
},
updated_at: {
allowNull: false,
type: Sequelize.DATE,
defaultValue: Sequelize.literal(
'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'
)
}
});
await queryInterface.addIndex('banners', ['position']);
await queryInterface.addIndex('banners', ['is_active']);
},
async down(queryInterface, Sequelize) {
await queryInterface.dropTable('banners');
}
};