forked from MarkUsProject/Markus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
peer_review: remove unnecessary peer_review_id foreign key that was c…
…reating a circular reference
- Loading branch information
1 parent
e5901ff
commit d546080
Showing
7 changed files
with
27 additions
and
32 deletions.
There are no files selected for viewing
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
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
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
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
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
14 changes: 14 additions & 0 deletions
14
db/migrate/20221219204837_remove_peer_review_id_from_results.rb
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,14 @@ | ||
class RemovePeerReviewIdFromResults < ActiveRecord::Migration[7.0] | ||
def up | ||
remove_column :results, :peer_review_id | ||
end | ||
def down | ||
add_reference :results, :peer_review, index: true | ||
add_foreign_key :results, :peer_reviews, on_delete: :cascade | ||
puts '-- Assigning peer review ids to results' | ||
Result.includes(:peer_reviews).find_each do |result| | ||
peer_review_id = result.peer_reviews.first&.id | ||
result.update!(peer_review_id: peer_review_id) unless peer_review_id.nil? | ||
end | ||
end | ||
end |
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