WMS_MAIN/database/migrations/20260717150000-add-camera-device-fields.js
liufumingren b485f8e9f1 feat(camera): 新增摄像头/录制模块 (camera/camera_server/pack_task_video)
- 新增 model: camera, camera_server

- 新增 services: camera, cameraServer (systemMethods + systems)

- 新增 pack_task_video 表及录制状态管理

- 7 条迁移: 建表→设备字段→端口拆分→状态枚举
2026-07-27 03:46:51 +08:00

56 lines
1.9 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';
const TABLE_NAME = 'wms_camera';
/**
* 新增摄像头设备信息字段:IP、SDK端口、型号、序列号、码流类型。
* 用于保存 NVR 服务器返回的摄像头详细设备信息。
*/
module.exports = {
up: async (queryInterface, Sequelize) => {
const columns = [
{
name: 'ip',
def: { type: Sequelize.STRING(50), allowNull: true, comment: '摄像头IP地址', after: 'channel_name' },
},
{
name: 'port',
def: { type: Sequelize.INTEGER.UNSIGNED, allowNull: true, comment: 'SDK管理端口(通常2020/8000)', after: 'ip' },
},
{
name: 'model',
def: { type: Sequelize.STRING(100), allowNull: true, comment: '摄像头型号', after: 'port' },
},
{
name: 'serial_number',
def: { type: Sequelize.STRING(100), allowNull: true, comment: '摄像头序列号', after: 'model' },
},
{
name: 'stream_type',
def: { type: Sequelize.STRING(20), allowNull: true, comment: '码流类型(auto/main/sub)', after: 'serial_number' },
},
];
for (const col of columns) {
const tableInfo = await queryInterface.describeTable(TABLE_NAME);
if (!tableInfo[col.name]) {
await queryInterface.addColumn(TABLE_NAME, col.name, col.def);
console.log(`[Migration] wms_camera.${col.name} 已添加`);
} else {
console.log(`[Migration] wms_camera.${col.name} 已存在,跳过`);
}
}
},
down: async queryInterface => {
const columns = ['stream_type', 'serial_number', 'model', 'port', 'ip'];
for (const col of columns) {
const tableInfo = await queryInterface.describeTable(TABLE_NAME);
if (tableInfo[col]) {
await queryInterface.removeColumn(TABLE_NAME, col);
console.log(`[Migration] wms_camera.${col} 已移除`);
}
}
},
};