bmc_hub/migrations/206_normalize_bmc_networks_heads.sql

16 lines
465 B
MySQL
Raw Normal View History

WITH bmc_owner AS (
SELECT MIN(id) AS id
FROM customers
WHERE lower(name) = 'bmc networks'
AND is_active = true
)
UPDATE internet_connections_connections ic
SET customer_id = COALESCE((SELECT id FROM bmc_owner), ic.customer_id),
allocation_model = 'shared',
value_type = 'bmc_networks',
value_label = NULL,
updated_at = CURRENT_TIMESTAMP
WHERE ic.deleted_at IS NULL
AND ic.parent_id IS NULL
AND ic.value_type = 'bmc_networks';