Skip to content

Commit 9c462aa

Browse files
committed
fix: [PPT-2355] Allow user deletion after signage use
1 parent 0d5de3a commit 9c462aa

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- +micrate Up
2+
-- SQL in section 'Up' is executed when this migration is applied
3+
4+
ALTER TABLE playlist_revisions ALTER COLUMN user_id DROP NOT NULL;
5+
6+
-- +micrate Down
7+
-- SQL section 'Down' is executed when this migration is rolled back
8+
9+
ALTER TABLE playlist_revisions ALTER COLUMN user_id SET NOT NULL;

spec/playlist_revision_spec.cr

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,18 @@ module PlaceOS::Model
180180
playlist.revisions.to_a.map(&.id).should eq [revision3.id, revision.id]
181181
playlist.revision.id.should eq revision3.id
182182
end
183+
it "allows user deletion when linked to a revision" do
184+
user = Generator.user.save!
185+
revision = Generator.revision
186+
revision.user = user
187+
revision.save!
188+
189+
# Should not raise foreign key constraint error
190+
user.delete
191+
192+
# Verify nullification
193+
reloaded = Playlist::Revision.find(revision.id.as(String))
194+
reloaded.user_id.should be_nil
195+
end
183196
end
184197
end

0 commit comments

Comments
 (0)