bmc_hub/migrations/225_hardware_network_links.sql
Christian be68148448 feat(email): add RETURNING id to email activity log insert
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
2026-07-18 10:10:31 +02:00

21 lines
847 B
SQL

CREATE TABLE IF NOT EXISTS hardware_network_links (
id SERIAL PRIMARY KEY,
source_hardware_id INTEGER NOT NULL REFERENCES hardware_assets(id) ON DELETE CASCADE,
source_port VARCHAR(100) NOT NULL,
target_hardware_id INTEGER NOT NULL REFERENCES hardware_assets(id) ON DELETE CASCADE,
target_port VARCHAR(100),
notes TEXT,
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
deleted_at TIMESTAMP,
CHECK (source_hardware_id <> target_hardware_id)
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_hardware_network_links_source_port_active
ON hardware_network_links(source_hardware_id, source_port)
WHERE deleted_at IS NULL;
CREATE INDEX IF NOT EXISTS idx_hardware_network_links_target_active
ON hardware_network_links(target_hardware_id)
WHERE deleted_at IS NULL;