mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
updated db migration
This commit is contained in:
@@ -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');
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user