packServer/backend/database/migrations/20261018200000-add-workstation-layout.js

78 lines
2.8 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';
/**
* 工作台画面布局
*
* 用途:一个工作台可以绑定多个摄像头,后续要把它们**拼成一路**(录制/合成),
* 所以每条绑定都要记住它在输出画布上的位置和大小,以及取哪路码流。
*
* - workstations.canvas_width / canvas_height:输出画布(默认 1920×1080)
* - workstation_cameras.x / y / width / height:在该画布上的矩形(像素)
* - workstation_cameras.stream_type:0=主码流 1=子码流
* - workstation_cameras.z_index:叠放顺序(大的在上层)
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('workstations', 'canvas_width', {
type: Sequelize.INTEGER.UNSIGNED,
allowNull: false,
defaultValue: 1920,
comment: '合成画布宽',
});
await queryInterface.addColumn('workstations', 'canvas_height', {
type: Sequelize.INTEGER.UNSIGNED,
allowNull: false,
defaultValue: 1080,
comment: '合成画布高',
});
await queryInterface.addColumn('workstation_cameras', 'x', {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '画布左上角 x',
});
await queryInterface.addColumn('workstation_cameras', 'y', {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '画布左上角 y',
});
await queryInterface.addColumn('workstation_cameras', 'width', {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '宽(0 = 用整张画布)',
});
await queryInterface.addColumn('workstation_cameras', 'height', {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '高(0 = 用整张画布)',
});
await queryInterface.addColumn('workstation_cameras', 'stream_type', {
type: Sequelize.TINYINT.UNSIGNED,
allowNull: false,
defaultValue: 0,
comment: '取流类型:0 主码流 1 子码流',
});
await queryInterface.addColumn('workstation_cameras', 'z_index', {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '叠放顺序(大的在上)',
});
},
async down(queryInterface) {
await queryInterface.removeColumn('workstation_cameras', 'z_index');
await queryInterface.removeColumn('workstation_cameras', 'stream_type');
await queryInterface.removeColumn('workstation_cameras', 'height');
await queryInterface.removeColumn('workstation_cameras', 'width');
await queryInterface.removeColumn('workstation_cameras', 'y');
await queryInterface.removeColumn('workstation_cameras', 'x');
await queryInterface.removeColumn('workstations', 'canvas_height');
await queryInterface.removeColumn('workstations', 'canvas_width');
},
};