-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added migration to update impressions and year_totals records to refe…
…rence authorities instead of people
- Loading branch information
Showing
2 changed files
with
22 additions
and
33 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class UpdatePeopleImpressions < ActiveRecord::Migration[6.1] | ||
def change | ||
execute <<~SQL | ||
update impressions i set | ||
impressionable_type = 'Authority', | ||
impressionable_id = (select a.id from authorities a where a.person_id = i.impressionable_id) | ||
where | ||
impressionable_type = 'Person' | ||
SQL | ||
|
||
execute <<~SQL | ||
update year_totals yt set | ||
item_type = 'Authority', | ||
item_id = (select a.id from authorities a where a.person_id = yt.item_id) | ||
where | ||
item_type = 'Person' | ||
SQL | ||
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