Files
starr-philproperties/database/migrations/20270101000052-create-page-sections.js
T

60 lines
1.7 KiB
JavaScript

'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('page_sections', {
id: {
type: Sequelize.BIGINT,
autoIncrement: true,
primaryKey: true,
},
page_id: {
type: Sequelize.BIGINT,
allowNull: false,
references: { model: 'pages', key: 'id' },
onDelete: 'CASCADE',
},
type: {
type: Sequelize.ENUM('hero', 'features', 'cta', 'testimonials', 'faq', 'pricing', 'gallery', 'custom'),
allowNull: false,
},
label: {
type: Sequelize.STRING(255),
allowNull: true,
},
position: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
},
settings: {
type: Sequelize.JSON,
allowNull: true,
comment: 'Background, padding, layout, and other section-level style overrides.',
},
is_visible: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true,
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
},
});
await queryInterface.addIndex('page_sections', { fields: ['page_id'], name: 'idx_page_sections_page_id' });
await queryInterface.addIndex('page_sections', { fields: ['page_id', 'position'], name: 'idx_page_sections_order' });
},
async down(queryInterface) {
await queryInterface.dropTable('page_sections');
},
};