add/delete cycle updates, shifting more to socketIO plus support for two device types

This commit is contained in:
2025-12-24 18:39:48 -06:00
parent 0658c47230
commit c67e30d5c6
2 changed files with 124 additions and 16 deletions

View File

@@ -0,0 +1,20 @@
-- Migration: Add max_ports column to devices table to support different device types
-- BlindMaster-C6: max_ports = 1 (single servo)
-- BlindMaster Device: max_ports = 4 (multi-port)
-- Add max_ports column with default value of 4 for existing devices
ALTER TABLE devices
ADD COLUMN max_ports INTEGER NOT NULL DEFAULT 4;
-- Add a check constraint to ensure max_ports is between 1 and 4
ALTER TABLE devices
ADD CONSTRAINT devices_max_ports_check CHECK (max_ports >= 1 AND max_ports <= 4);
-- For existing devices, you may want to set max_ports based on the number of peripherals
-- Uncomment the following line if you want to auto-detect based on existing peripherals:
-- UPDATE devices d SET max_ports = GREATEST(1, (SELECT COUNT(*) FROM peripherals p WHERE p.device_id = d.id));
-- Create an index for faster queries
CREATE INDEX idx_devices_max_ports ON devices(max_ports);
COMMENT ON COLUMN devices.max_ports IS 'Maximum number of ports/peripherals this device supports (1 for C6, 4 for multi-port)';