Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- +micrate Up
-- SQL in section 'Up' is executed when this migration is applied

ALTER TABLE playlist_revisions ALTER COLUMN user_id DROP NOT NULL;

-- +micrate Down
-- SQL section 'Down' is executed when this migration is rolled back

ALTER TABLE playlist_revisions ALTER COLUMN user_id SET NOT NULL;
13 changes: 13 additions & 0 deletions spec/playlist_revision_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,18 @@ module PlaceOS::Model
playlist.revisions.to_a.map(&.id).should eq [revision3.id, revision.id]
playlist.revision.id.should eq revision3.id
end
it "allows user deletion when linked to a revision" do
user = Generator.user.save!
revision = Generator.revision
revision.user = user
revision.save!

# Should not raise foreign key constraint error
user.delete

# Verify nullification
reloaded = Playlist::Revision.find(revision.id.as(String))
reloaded.user_id.should be_nil
end
end
end
Loading