Skip to content

Commit

Permalink
Delete disallowed mobile devices from database
Browse files Browse the repository at this point in the history
  • Loading branch information
akheron committed Dec 16, 2024
1 parent 5c7b891 commit 246b1a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
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);
1 change: 1 addition & 0 deletions service/src/main/resources/migrations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -472,3 +472,4 @@ V473__person_municipality_of_residence.sql
V474__holiday_questionnaire_open_ranges.sql
V475__application_modified_metadata.sql
V476__finance_metadata_process.sql
V477__delete_disallowed_personal_mobile_pairings.sql

0 comments on commit 246b1a6

Please sign in to comment.