-
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.
Merge pull request #993 from PRX/feat/simplify_apple_config_associations
Apple::Config only belongs to the private feed
- Loading branch information
Showing
18 changed files
with
161 additions
and
180 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
32 changes: 32 additions & 0 deletions
32
db/migrate/20240410212602_simplify_apple_config_foreign_keys.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,32 @@ | ||
class SimplifyAppleConfigForeignKeys < ActiveRecord::Migration[7.0] | ||
def up | ||
Apple::Config.find_each do |ac| | ||
unless ac[:public_feed_id] == Podcast.find(ac[:podcast_id]).default_feed.id | ||
raise "Apple::Config[#{ac.id} is not using the podcast.default_feed" | ||
end | ||
end | ||
|
||
remove_column :apple_configs, :podcast_id | ||
remove_column :apple_configs, :public_feed_id | ||
rename_column :apple_configs, :private_feed_id, :feed_id | ||
end | ||
|
||
def down | ||
add_column :apple_configs, :podcast_id, :integer | ||
add_index :apple_configs, [:podcast_id], unique: true | ||
|
||
add_reference :apple_configs, :public_feed, index: true | ||
add_foreign_key :apple_configs, :feeds, column: :public_feed_id | ||
|
||
rename_column :apple_configs, :feed_id, :private_feed_id | ||
|
||
Apple::Config.find_each do |ac| | ||
f = Feed.find(ac.private_feed_id) | ||
ac.podcast_id = f.podcast.id | ||
ac.public_feed_id = f.podcast.default_feed.id | ||
ac.save!(validate: false) | ||
end | ||
|
||
change_column_null :apple_configs, :public_feed_id, false | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.