Files
competition-website/database/migrations/006-create-carousel.js
WorkBuddy a303cf2d53 chore: 后端首次基线提交
运行必须源码:app/(controller/model/service/middleware/lib/utils/validate/router)、config/、database/(migrations/seeders/sql)、启动脚本、app/public/templates 模板。
已忽略运行非必须:node_modules/、logs/、run/、app/public 运行时上传数据、.env*、构建/缓存产物。
2026-08-17 12:25:42 +08:00

59 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('carousel', {
id: {
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '轮播图ID',
},
image_url: {
type: Sequelize.STRING(512),
allowNull: false,
comment: '图片URL',
},
sort_order: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序序号',
},
link_url: {
type: Sequelize.STRING(512),
allowNull: true,
comment: '点击跳转链接',
},
enabled: {
type: Sequelize.TINYINT,
allowNull: false,
defaultValue: 1,
comment: '是否启用:0禁用 1启用',
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
comment: '更新时间',
},
}).then(() => {
return Promise.all([
queryInterface.addIndex('carousel', ['sort_order'], { name: 'idx_sort_order' }),
queryInterface.addIndex('carousel', ['enabled'], { name: 'idx_enabled' }),
]);
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('carousel');
},
};