20 lines
661 B
MySQL
20 lines
661 B
MySQL
|
|
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')
|
||
|
|
)
|
||
|
|
);
|