bmc_hub/migrations/1024_internet_connections_manual_delefiber.sql

20 lines
661 B
MySQL
Raw Normal View History

ALTER TABLE internet_connections_connections
ADD COLUMN IF NOT EXISTS is_manual_shared BOOLEAN NOT NULL DEFAULT FALSE;
UPDATE internet_connections_connections parent
SET is_manual_shared = TRUE
WHERE parent.deleted_at IS NULL
AND parent.parent_id IS NULL
AND parent.allocation_model = 'shared'
AND parent.value_type = 'delefiber'
AND NOT EXISTS (
SELECT 1
FROM internet_connections_connections child
WHERE child.parent_id = parent.id
AND child.deleted_at IS NULL
AND (
child.value_type = 'subscription'
OR LOWER(COALESCE(child.value_label, '')) IN ('bmcnet', 'bmc networks')
)
);