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
17 lines
615 B
SQL
17 lines
615 B
SQL
ALTER TABLE hardware_assets
|
|
ADD COLUMN IF NOT EXISTS location_display_order INTEGER;
|
|
|
|
WITH ordered AS (
|
|
SELECT id, ROW_NUMBER() OVER (PARTITION BY current_location_id ORDER BY brand, model, serial_number, id) AS row_number
|
|
FROM hardware_assets
|
|
WHERE current_location_id IS NOT NULL AND location_display_order IS NULL
|
|
)
|
|
UPDATE hardware_assets h
|
|
SET location_display_order = ordered.row_number
|
|
FROM ordered
|
|
WHERE h.id = ordered.id;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_hardware_assets_location_display_order
|
|
ON hardware_assets(current_location_id, location_display_order)
|
|
WHERE deleted_at IS NULL;
|