updated db migration

This commit is contained in:
2026-07-20 12:28:46 +08:00
parent a2c9936f79
commit d665897ef5
129 changed files with 574 additions and 1878 deletions
@@ -0,0 +1,55 @@
'use strict';
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('page_blocks', {
id: {
type: Sequelize.BIGINT,
autoIncrement: true,
primaryKey: true,
},
page_section_id: {
type: Sequelize.BIGINT,
allowNull: false,
references: { model: 'page_sections', key: 'id' },
onDelete: 'CASCADE',
},
type: {
type: Sequelize.ENUM('text', 'image', 'button', 'video', 'form', 'spacer'),
allowNull: false,
},
content: {
type: Sequelize.JSON,
allowNull: true,
comment: 'Block payload — varies by type (e.g. src + alt for image, href + label for button).',
},
position: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
},
settings: {
type: Sequelize.JSON,
allowNull: true,
comment: 'Block-level style overrides: alignment, color, font size, etc.',
},
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_blocks', { fields: ['page_section_id'], name: 'idx_page_blocks_section_id' });
await queryInterface.addIndex('page_blocks', { fields: ['page_section_id', 'position'], name: 'idx_page_blocks_order' });
},
async down(queryInterface) {
await queryInterface.dropTable('page_blocks');
},
};