feat(ollama): implement case creation rewrite with strict rules fix(sync): include phone number in economic customer sync fix(migrations): clean up orphan links before enforcing foreign keys in email threading schema feat(migrations): add support for physical patch-panel layouts and update related constraints feat(migrations): add start port number for physical patch panels feat(migrations): introduce display order for physical panels feat(migrations): link wall outlets to switch hardware feat(migrations): allow optional label and customer for wall outlets feat(migrations): create hardware network links table feat(migrations): add location display order for hardware assets feat(migrations): create UISP devices and link to hardware assets
40 lines
1.5 KiB
SQL
40 lines
1.5 KiB
SQL
-- Support physical patch-panel layouts such as 1A, 1B … 24A, 24B.
|
|
ALTER TABLE locations_cross_fields
|
|
ADD COLUMN IF NOT EXISTS port_label_format VARCHAR(20) NOT NULL DEFAULT 'numeric',
|
|
ADD COLUMN IF NOT EXISTS panel_row_size INTEGER NOT NULL DEFAULT 24;
|
|
|
|
ALTER TABLE locations_cross_fields
|
|
DROP CONSTRAINT IF EXISTS locations_cross_fields_port_label_format_check;
|
|
ALTER TABLE locations_cross_fields
|
|
ADD CONSTRAINT locations_cross_fields_port_label_format_check
|
|
CHECK (port_label_format IN ('numeric', 'paired'));
|
|
|
|
ALTER TABLE locations_cross_fields
|
|
DROP CONSTRAINT IF EXISTS locations_cross_fields_panel_row_size_check;
|
|
ALTER TABLE locations_cross_fields
|
|
ADD CONSTRAINT locations_cross_fields_panel_row_size_check
|
|
CHECK (panel_row_size BETWEEN 1 AND 48);
|
|
|
|
-- Port labels are physical labels, not necessarily numbers (for example 1A/1B).
|
|
ALTER TABLE locations_cross_field_ports
|
|
DROP CONSTRAINT IF EXISTS locations_cross_field_ports_port_number_check;
|
|
|
|
ALTER TABLE locations_cross_field_ports
|
|
ALTER COLUMN port_number TYPE VARCHAR(20) USING port_number::VARCHAR;
|
|
|
|
ALTER TABLE locations_cross_field_ports
|
|
ADD COLUMN IF NOT EXISTS port_order INTEGER;
|
|
|
|
UPDATE locations_cross_field_ports
|
|
SET port_order = CASE
|
|
WHEN port_number ~ '^[0-9]+$' THEN port_number::INTEGER
|
|
ELSE id
|
|
END
|
|
WHERE port_order IS NULL;
|
|
|
|
ALTER TABLE locations_cross_field_ports
|
|
ALTER COLUMN port_order SET NOT NULL;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_cross_field_ports_field_order
|
|
ON locations_cross_field_ports(cross_field_id, port_order);
|