73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
'use strict';
|
||
|
||
const TABLE_NAME = 'wms_pack_task_video';
|
||
|
||
module.exports = {
|
||
up: async (queryInterface, Sequelize) => {
|
||
const tables = await queryInterface.showAllTables();
|
||
const exists = tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE_NAME);
|
||
if (exists) return;
|
||
|
||
await queryInterface.createTable(TABLE_NAME, {
|
||
id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
allowNull: false,
|
||
comment: '主键ID',
|
||
},
|
||
pack_task_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '打包任务ID,关联 wms_pack_task.id',
|
||
},
|
||
camera_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: true,
|
||
comment: '摄像头设备ID,关联 wms_camera.id',
|
||
},
|
||
video_url: {
|
||
type: Sequelize.STRING(500),
|
||
allowNull: false,
|
||
comment: '视频地址(录像回放URL)',
|
||
},
|
||
status: {
|
||
type: Sequelize.TINYINT,
|
||
allowNull: false,
|
||
defaultValue: 1,
|
||
comment: '状态:0-无效 1-有效',
|
||
},
|
||
remark: {
|
||
type: Sequelize.STRING(500),
|
||
allowNull: true,
|
||
comment: '备注',
|
||
},
|
||
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: '更新时间',
|
||
},
|
||
deleted_at: {
|
||
type: Sequelize.DATE,
|
||
allowNull: true,
|
||
comment: '软删除时间',
|
||
},
|
||
});
|
||
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'pack_task_id' ], { name: 'idx_pack_task_id' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'camera_id' ], { name: 'idx_camera_id' });
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' });
|
||
},
|
||
|
||
down: async queryInterface => {
|
||
await queryInterface.dropTable(TABLE_NAME);
|
||
},
|
||
};
|