'use strict'; /** * 创建退回拆包视频记录表 wms_return_unpack_video(参考 wms_pack_task_video)。 * * 字段:关联主表 unpack_id、摄像头 camera_id(非必填)、视频地址 video_url、状态 status、 * 备注 remark、软删除 deleted_at(paranoid)。 * * 索引:idx_unpack_id(按拆包单查视频)、idx_camera_id(按摄像头反查)、idx_deleted_at(软删除优化)。 */ const TABLE_NAME = 'wms_return_unpack_video'; module.exports = { // eslint-disable-next-line no-unused-vars async up(queryInterface, Sequelize) { const { BIGINT, STRING, DATE, ENUM } = Sequelize; await queryInterface.createTable(TABLE_NAME, { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, unpack_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '关联拆包主表 wms_return_unpack.id', }, camera_id: { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '摄像头设备ID,关联 wms_camera.id', }, video_url: { type: STRING(500), allowNull: false, comment: '视频地址(录像回放URL)', }, status: { type: ENUM('created', 'recording', 'completed', 'failed'), allowNull: false, defaultValue: 'created', comment: '状态:created/recording/completed/failed', }, remark: { type: STRING(500), allowNull: true, comment: '备注', }, created_at: { type: DATE, allowNull: false }, updated_at: { type: DATE, allowNull: false }, deleted_at: { type: DATE, allowNull: true, comment: '软删除时间' }, }); await queryInterface.addIndex(TABLE_NAME, [ 'unpack_id' ], { name: 'idx_unpack_id' }); await queryInterface.addIndex(TABLE_NAME, [ 'camera_id' ], { name: 'idx_camera_id' }); await queryInterface.addIndex(TABLE_NAME, [ 'deleted_at' ], { name: 'idx_deleted_at' }); }, // eslint-disable-next-line no-unused-vars async down(queryInterface, Sequelize) { await queryInterface.dropTable(TABLE_NAME); }, };