Skip to content

Commit

Permalink
Merge pull request #2777 from ministryofjustice/CAS1343-delete-cas1-l…
Browse files Browse the repository at this point in the history
…ost-beds-from-lostbeds-table

CAS-1343 Delete CAS1 lost beds from lost_beds and lost_bed_cancellations tables
  • Loading branch information
muhammad-elabdulla authored Jan 9, 2025
2 parents a4f5b00 + b55f68c commit b99a638
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
ALTER TABLE lost_beds DROP CONSTRAINT lost_bed_reason_id_fk;
ALTER TABLE lost_bed_cancellations DROP CONSTRAINT lost_bed_cancellations_lost_bed_id_fkey;

DELETE FROM lost_bed_cancellations
WHERE lost_bed_id in(
SELECT id
FROM lost_beds
where premises_id in (select id from premises where service='approved-premises'));

DELETE FROM lost_beds
where premises_id in (select id from premises where service='approved-premises');

ALTER TABLE lost_beds RENAME TO cas3_void_bedspaces;

ALTER TABLE lost_bed_cancellations RENAME TO cas3_void_bedspace_cancellations;
Expand Down

0 comments on commit b99a638

Please sign in to comment.