'use strict'; /** * 为 carousel 表新增富文本正文与可配置按钮字段,并放宽 image_url 允许为空 * (支持"渐变底图回退"的固定页迁移)。 * * 新增: * - content TEXT 富文本正文(HTML,由 wangEditor 生成,前端 v-html 渲染) * - button_text VARCHAR(100) 按钮文字(为空则不显示按钮) * - button_link VARCHAR(500) 按钮链接(内部路由如 /activate,或外部 http(s):// 链接) * 变更: * - image_url 由 NOT NULL 放宽为 允许 NULL(无底图时前端回退 CSS 渐变) */ module.exports = { up: async (queryInterface, Sequelize) => { await queryInterface.addColumn('carousel', 'content', { type: Sequelize.TEXT, allowNull: true, defaultValue: null, comment: '富文本正文(HTML)', after: 'title', }); await queryInterface.addColumn('carousel', 'button_text', { type: Sequelize.STRING(100), allowNull: true, defaultValue: null, comment: '按钮文字(为空则不显示按钮)', after: 'content', }); await queryInterface.addColumn('carousel', 'button_link', { type: Sequelize.STRING(500), allowNull: true, defaultValue: null, comment: '按钮链接(内部路由/外部URL)', after: 'button_text', }); // 放宽 image_url 允许为空,支持渐变底图回退 await queryInterface.changeColumn('carousel', 'image_url', { type: Sequelize.STRING(500), allowNull: true, defaultValue: null, comment: '图片 URL 地址(可为空时前端回退渐变)', }); }, down: async (queryInterface, Sequelize) => { await queryInterface.removeColumn('carousel', 'content'); await queryInterface.removeColumn('carousel', 'button_text'); await queryInterface.removeColumn('carousel', 'button_link'); await queryInterface.changeColumn('carousel', 'image_url', { type: Sequelize.STRING(500), allowNull: false, comment: '图片 URL 地址', }); }, };