-- Direct, customer-independent links between cases and internet connections. CREATE TABLE IF NOT EXISTS sag_internet_connections ( sag_id INTEGER NOT NULL REFERENCES sag_sager(id) ON DELETE CASCADE, connection_id INTEGER NOT NULL REFERENCES internet_connections_connections(id) ON DELETE RESTRICT, linked_by_user_id INTEGER REFERENCES users(user_id) ON DELETE SET NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), PRIMARY KEY (sag_id, connection_id) ); CREATE INDEX IF NOT EXISTS idx_sag_internet_connections_connection ON sag_internet_connections(connection_id, created_at DESC);