WMS_MAIN/database/migrations/20260730000000-add-camera-username-password.js
liufumingren 45b59ea35c feat(camera): 新增摄像头 OSD 叠加功能
- 新增 camera model username/password 字段
- 新增 osd_client.js OSD 客户端库
- 工作台打包时自动叠加 OSD 信息到摄像头(带 Redis 缓存去重)
- 新增迁移脚本:摄像头用户名密码字段
2026-08-01 03:44:02 +08:00

44 lines
1.3 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';
/**
* 新增摄像头认证字段:username(用户名)、password(密码)。
* 用于保存摄像头登录认证信息。
*/
module.exports = {
up: async (queryInterface, Sequelize) => {
const columns = [
{
name: 'username',
def: { type: Sequelize.STRING(100), allowNull: true, comment: '摄像头登录用户名', after: 'stream_type' },
},
{
name: 'password',
def: { type: Sequelize.STRING(100), allowNull: true, comment: '摄像头登录密码', after: 'username' },
},
];
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 = ['password', 'username'];
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} 已回滚删除`);
}
}
},
};