-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Delete disallowed mobile devices from database
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
service/src/main/resources/db/migration/V477__delete_disallowed_personal_mobile_pairings.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
WITH disallowed_devices AS ( | ||
SELECT id | ||
FROM mobile_device | ||
WHERE | ||
employee_id IS NOT NULL AND | ||
NOT EXISTS ( | ||
SELECT FROM daycare_acl a | ||
JOIN daycare d ON d.id = a.daycare_id | ||
WHERE | ||
d.provider_type = 'MUNICIPAL' AND | ||
a.employee_id = mobile_device.employee_id AND | ||
a.role = 'UNIT_SUPERVISOR' | ||
) | ||
), push_subscriptions AS ( | ||
DELETE FROM mobile_device_push_subscription | ||
WHERE device IN (SELECT id FROM disallowed_devices) | ||
), push_groups AS ( | ||
DELETE FROM mobile_device_push_group | ||
WHERE device IN (SELECT id FROM disallowed_devices) | ||
), pairings AS ( | ||
DELETE FROM pairing | ||
WHERE mobile_device_id IN (SELECT id FROM disallowed_devices) | ||
) | ||
DELETE FROM mobile_device | ||
WHERE id IN (SELECT id FROM disallowed_devices); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters