From 4ecd1ab5c85e776aff8cf467f0a9540deb262398 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Mon, 1 Apr 2019 21:07:09 -0700 Subject: [PATCH 1/5] Don't papertrail things that shouldn't be paper trailed. Closes #1630 --- app/models/potential_payment.rb | 1 - app/models/site_channel_details.rb | 1 - app/models/twitch_channel_details.rb | 1 - app/models/twitter_channel_details.rb | 1 - app/models/youtube_channel_details.rb | 1 - .../remove_unused_versions.rake | 19 +++++++++++++++++++ 6 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 lib/tasks/database_updates/remove_unused_versions.rake diff --git a/app/models/potential_payment.rb b/app/models/potential_payment.rb index 1945aef129..ff02319b66 100644 --- a/app/models/potential_payment.rb +++ b/app/models/potential_payment.rb @@ -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 diff --git a/app/models/site_channel_details.rb b/app/models/site_channel_details.rb index 46d5a70aef..1f54355884 100644 --- a/app/models/site_channel_details.rb +++ b/app/models/site_channel_details.rb @@ -1,5 +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 diff --git a/app/models/twitch_channel_details.rb b/app/models/twitch_channel_details.rb index 0400d6c49f..09c20eccfa 100644 --- a/app/models/twitch_channel_details.rb +++ b/app/models/twitch_channel_details.rb @@ -1,5 +1,4 @@ class TwitchChannelDetails < BaseChannelDetails - has_paper_trail validate :twitch_channel_not_changed_once_initialized validates :twitch_channel_id, presence: true diff --git a/app/models/twitter_channel_details.rb b/app/models/twitter_channel_details.rb index b605fc3640..3a18460bf3 100644 --- a/app/models/twitter_channel_details.rb +++ b/app/models/twitter_channel_details.rb @@ -1,5 +1,4 @@ class TwitterChannelDetails < BaseChannelDetails - has_paper_trail validate :twitter_channel_not_changed_once_initialized validates :twitter_channel_id, presence: true diff --git a/app/models/youtube_channel_details.rb b/app/models/youtube_channel_details.rb index 95c424a4e9..4877a5b15e 100644 --- a/app/models/youtube_channel_details.rb +++ b/app/models/youtube_channel_details.rb @@ -1,5 +1,4 @@ class YoutubeChannelDetails < BaseChannelDetails - has_paper_trail validate :youtube_channel_not_changed_once_initialized validates :youtube_channel_id, presence: true diff --git a/lib/tasks/database_updates/remove_unused_versions.rake b/lib/tasks/database_updates/remove_unused_versions.rake new file mode 100644 index 0000000000..e765df6bf4 --- /dev/null +++ b/lib/tasks/database_updates/remove_unused_versions.rake @@ -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 From edde5834e5b2936c5d3485a92ad68940d0acd63f Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 4 Jun 2019 17:21:35 -0700 Subject: [PATCH 2/5] Update youtube_channel_details.rb --- app/models/youtube_channel_details.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/youtube_channel_details.rb b/app/models/youtube_channel_details.rb index 4877a5b15e..060bbb5407 100644 --- a/app/models/youtube_channel_details.rb +++ b/app/models/youtube_channel_details.rb @@ -1,5 +1,4 @@ class YoutubeChannelDetails < BaseChannelDetails - validate :youtube_channel_not_changed_once_initialized validates :youtube_channel_id, presence: true validates :title, presence: true From d872cf0b9c423c4929ff90957542cb43d18db9b1 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 4 Jun 2019 17:21:48 -0700 Subject: [PATCH 3/5] Update twitter_channel_details.rb --- app/models/twitter_channel_details.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/twitter_channel_details.rb b/app/models/twitter_channel_details.rb index 3a18460bf3..d8af63417c 100644 --- a/app/models/twitter_channel_details.rb +++ b/app/models/twitter_channel_details.rb @@ -1,5 +1,4 @@ class TwitterChannelDetails < BaseChannelDetails - validate :twitter_channel_not_changed_once_initialized validates :twitter_channel_id, presence: true validates :thumbnail_url, presence: true From 7469bb88eb3c51bc1d4783e7dd11039561440b9e Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 4 Jun 2019 17:21:59 -0700 Subject: [PATCH 4/5] Update twitch_channel_details.rb --- app/models/twitch_channel_details.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/twitch_channel_details.rb b/app/models/twitch_channel_details.rb index 09c20eccfa..690cdf5c0d 100644 --- a/app/models/twitch_channel_details.rb +++ b/app/models/twitch_channel_details.rb @@ -1,5 +1,4 @@ class TwitchChannelDetails < BaseChannelDetails - validate :twitch_channel_not_changed_once_initialized validates :twitch_channel_id, presence: true validates :thumbnail_url, presence: true From 0c6b431bfcf7b7c32779bdd557f008bad8ef0609 Mon Sep 17 00:00:00 2001 From: Albert Wang Date: Tue, 4 Jun 2019 17:22:16 -0700 Subject: [PATCH 5/5] Update site_channel_details.rb --- app/models/site_channel_details.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/site_channel_details.rb b/app/models/site_channel_details.rb index 1f54355884..c6cd2a6965 100644 --- a/app/models/site_channel_details.rb +++ b/app/models/site_channel_details.rb @@ -1,5 +1,4 @@ class SiteChannelDetails < BaseChannelDetails - # 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.