Skip to content

Commit

Permalink
Merge pull request #1777 from yachtcaptain23/techdebt/paper_trail_exc…
Browse files Browse the repository at this point in the history
…esses

Don't papertrail things that shouldn't be paper trailed. Closes #1630
  • Loading branch information
yachtcaptain23 authored Jun 5, 2019
2 parents bc28d2a + 0c6b431 commit 0505acc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
1 change: 0 additions & 1 deletion app/models/potential_payment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ class PotentialPayment < ApplicationRecord
REFERRAL = "referral".freeze
CONTRIBUTION = "contribution".freeze
MANUAL = "manual".freeze
has_paper_trail

belongs_to :payout_report
belongs_to :publisher
Expand Down
2 changes: 0 additions & 2 deletions app/models/site_channel_details.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class SiteChannelDetails < BaseChannelDetails
has_paper_trail

# brave_publisher_id is a normalized identifier provided by eyeshade API
# It is like base domain (eTLD + left part) but may include additional
# formats to support more publishers.
Expand Down
2 changes: 0 additions & 2 deletions app/models/twitch_channel_details.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class TwitchChannelDetails < BaseChannelDetails
has_paper_trail

validate :twitch_channel_not_changed_once_initialized
validates :twitch_channel_id, presence: true
validates :thumbnail_url, presence: true
Expand Down
2 changes: 0 additions & 2 deletions app/models/twitter_channel_details.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class TwitterChannelDetails < BaseChannelDetails
has_paper_trail

validate :twitter_channel_not_changed_once_initialized
validates :twitter_channel_id, presence: true
validates :thumbnail_url, presence: true
Expand Down
2 changes: 0 additions & 2 deletions app/models/youtube_channel_details.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
class YoutubeChannelDetails < BaseChannelDetails
has_paper_trail

validate :youtube_channel_not_changed_once_initialized
validates :youtube_channel_id, presence: true
validates :title, presence: true
Expand Down
19 changes: 19 additions & 0 deletions lib/tasks/database_updates/remove_unused_versions.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace :database_updates do
task :remove_unused_versions => :environment do
class LegacyVersion < ApplicationRecord ; end
class Version < ApplicationRecord ; end
puts "[#{Time.now.iso8601}] Starting migration to remove unused version details"

LegacyVersion.where(item_type: YoutubeChannelDetails.to_s).delete_all
LegacyVersion.where(item_type: SiteChannelDetails.to_s).delete_all
LegacyVersion.where(item_type: PotentialPayment.to_s).delete_all
LegacyVersion.where(item_type: TwitchChannelDetails.to_s).delete_all
LegacyVersion.where(item_type: TwitterChannelDetails.to_s).delete_all
Version.where(item_type: YoutubeChannelDetails.to_s).delete_all
Version.where(item_type: SiteChannelDetails.to_s).delete_all
Version.where(item_type: PotentialPayment.to_s).delete_all
Version.where(item_type: TwitchChannelDetails.to_s).delete_all
Version.where(item_type: TwitterChannelDetails.to_s).delete_all
puts "[#{Time.now.iso8601}] - migration complete ✨"
end
end

0 comments on commit 0505acc

Please sign in to comment.