This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #190 from ixti/fix/bulk_edit_journals
Fix/bulk edit journals
- Loading branch information
Showing
4 changed files
with
61 additions
and
18 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
12 changes: 12 additions & 0 deletions
12
db/migrate/20180122193833_remove_wrong_tag_list_journals.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,12 @@ | ||
class RemoveWrongTagListJournals < ActiveRecord::Migration | ||
def change | ||
# First, remove from journal details the tag changes where the new value is the same with the old_value | ||
JournalDetail.where("prop_key = 'tag_list' AND old_value = value").destroy_all | ||
|
||
# Remove all journals that do not have notes and neither attributes changes in the journal_details table | ||
Journal.joins("LEFT OUTER JOIN #{JournalDetail.table_name} ON #{JournalDetail.table_name}.journal_id = #{Journal.table_name}.id") | ||
.where("(#{Journal.table_name}.notes IS NULL OR #{Journal.table_name}.notes = '') AND #{Journal.table_name}.journalized_type = 'Issue'") | ||
.where("#{JournalDetail.table_name}.journal_id IS NULL") | ||
.destroy_all | ||
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
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