59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
|
|
'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');
|
|||
|
|
},
|
|||
|
|
};
|