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
21 lines
687 B
SQL
21 lines
687 B
SQL
-- Physical panels may be displayed in a different order than their names.
|
|
ALTER TABLE locations_cross_fields
|
|
ADD COLUMN IF NOT EXISTS display_order INTEGER;
|
|
|
|
WITH ordered AS (
|
|
SELECT id, ROW_NUMBER() OVER (PARTITION BY location_id ORDER BY name, id) AS row_number
|
|
FROM locations_cross_fields
|
|
WHERE display_order IS NULL
|
|
)
|
|
UPDATE locations_cross_fields cf
|
|
SET display_order = ordered.row_number
|
|
FROM ordered
|
|
WHERE cf.id = ordered.id;
|
|
|
|
ALTER TABLE locations_cross_fields
|
|
ALTER COLUMN display_order SET NOT NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_cross_fields_location_display_order
|
|
ON locations_cross_fields(location_id, display_order)
|
|
WHERE deleted_at IS NULL;
|