forked from openSUSE/osem
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
83 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class AddOrganizationToVersions < ActiveRecord::Migration[5.2] | ||
def up | ||
add_reference :versions, :organization | ||
deconflate | ||
end | ||
|
||
def down | ||
conflate | ||
remove_reference :versions, :organization | ||
end | ||
|
||
private | ||
|
||
def conflate | ||
say 'conflate' | ||
|
||
PaperTrail::Version.where.not(organization_id: nil).each do |version| | ||
version.update_attributes conference_id: version.organization_id | ||
end | ||
end | ||
|
||
def deconflate | ||
say 'deconflate' | ||
|
||
PaperTrail::Version.where.not(conference_id: nil).where(item_type: %[Role UsersRole]).each do |version| | ||
id = version.conference_id | ||
|
||
if Organization.exists?(id) | ||
raise "version #{version.id} conflates organization #{id} with conference #{id}" if Conference.exists?(id) | ||
|
||
version.update_attributes conference_id: nil, organization_id: id | ||
end | ||
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
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