about summary refs log tree commit diff
path: root/db
diff options
context:
space:
mode:
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb2
-rw-r--r--db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb2
-rw-r--r--db/migrate/20181024224956_migrate_account_conversations.rb3
-rw-r--r--db/migrate/20190314181829_migrate_open_registrations_setting.rb2
-rw-r--r--db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb4
-rw-r--r--db/migrate/20200510110808_reset_web_app_secret.rb3
-rw-r--r--db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb1
-rw-r--r--db/migrate/20220613110834_add_action_to_custom_filters.rb1
-rw-r--r--db/post_migrate/20200917193528_migrate_notifications_type.rb10
-rw-r--r--db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb1
-rw-r--r--db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb1
-rw-r--r--db/post_migrate/20221101190723_backfill_admin_action_logs.rb15
-rw-r--r--db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb15
13 files changed, 45 insertions, 15 deletions
diff --git a/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb b/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb
index 3e74346a8..86e425559 100644
--- a/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb
+++ b/db/migrate/20170610000000_add_statuses_index_on_account_id_id.rb
@@ -6,7 +6,7 @@ class AddStatusesIndexOnAccountIdId < ActiveRecord::Migration[5.1]
     # of an account to show them in his status page is one of the most
     # significant examples.
     # Add this index to improve the performance in such cases.
-    add_index 'statuses', ['account_id', 'id'], algorithm: :concurrently, name: 'index_statuses_on_account_id_id'
+    add_index 'statuses', %w(account_id id), algorithm: :concurrently, name: 'index_statuses_on_account_id_id'
 
     remove_index 'statuses', algorithm: :concurrently, column: 'account_id', name: 'index_statuses_on_account_id'
   end
diff --git a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb
index e23880bf5..c00302804 100644
--- a/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb
+++ b/db/migrate/20180514140000_revert_index_change_on_statuses_for_api_v1_accounts_account_id_statuses.rb
@@ -10,6 +10,6 @@ class RevertIndexChangeOnStatusesForApiV1AccountsAccountIdStatuses < ActiveRecor
 
     # These index may not exists (see migration 20180514130000)
     remove_index :statuses, column: [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)', algorithm: :concurrently if index_exists?(:statuses, [:account_id, :id, :visibility], where: 'visibility IN (0, 1, 2)')
-    remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, ['account_id', 'id'], where: '(visibility = 3)')
+    remove_index :statuses, column: [:account_id, :id], where: 'visibility = 3', algorithm: :concurrently if index_exists?(:statuses, %w(account_id id), where: '(visibility = 3)')
   end
 end
diff --git a/db/migrate/20181024224956_migrate_account_conversations.rb b/db/migrate/20181024224956_migrate_account_conversations.rb
index 9e6497d81..aca6638e1 100644
--- a/db/migrate/20181024224956_migrate_account_conversations.rb
+++ b/db/migrate/20181024224956_migrate_account_conversations.rb
@@ -100,8 +100,7 @@ class MigrateAccountConversations < ActiveRecord::Migration[5.2]
     end
   end
 
-  def down
-  end
+  def down; end
 
   private
 
diff --git a/db/migrate/20190314181829_migrate_open_registrations_setting.rb b/db/migrate/20190314181829_migrate_open_registrations_setting.rb
index e5fe95009..d2f6bf2c1 100644
--- a/db/migrate/20190314181829_migrate_open_registrations_setting.rb
+++ b/db/migrate/20190314181829_migrate_open_registrations_setting.rb
@@ -2,6 +2,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2]
   def up
     open_registrations = Setting.find_by(var: 'open_registrations')
     return if open_registrations.nil? || open_registrations.value
+
     setting = Setting.where(var: 'registrations_mode').first_or_initialize(var: 'registrations_mode')
     setting.update(value: 'none')
   end
@@ -9,6 +10,7 @@ class MigrateOpenRegistrationsSetting < ActiveRecord::Migration[5.2]
   def down
     registrations_mode = Setting.find_by(var: 'registrations_mode')
     return if registrations_mode.nil?
+
     setting = Setting.where(var: 'open_registrations').first_or_initialize(var: 'open_registrations')
     setting.update(value: registrations_mode.value == 'open')
   end
diff --git a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
index 72b7c609d..1c18b85cb 100644
--- a/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
+++ b/db/migrate/20190529143559_preserve_old_layout_for_existing_users.rb
@@ -8,10 +8,10 @@ class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2]
 
     User.where(User.arel_table[:current_sign_in_at].gteq(1.month.ago)).find_each do |user|
       next if Setting.unscoped.where(thing_type: 'User', thing_id: user.id, var: 'advanced_layout').exists?
+
       user.settings.advanced_layout = true
     end
   end
 
-  def down
-  end
+  def down; end
 end
diff --git a/db/migrate/20200510110808_reset_web_app_secret.rb b/db/migrate/20200510110808_reset_web_app_secret.rb
index b274844c5..8c0c06a83 100644
--- a/db/migrate/20200510110808_reset_web_app_secret.rb
+++ b/db/migrate/20200510110808_reset_web_app_secret.rb
@@ -10,6 +10,5 @@ class ResetWebAppSecret < ActiveRecord::Migration[5.2]
     web_app.save!
   end
 
-  def down
-  end
+  def down; end
 end
diff --git a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb
index 7f6a2c6dd..a3cc854d7 100644
--- a/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb
+++ b/db/migrate/20210421121431_add_case_insensitive_btree_index_to_tags.rb
@@ -11,6 +11,7 @@ class AddCaseInsensitiveBtreeIndexToTags < ActiveRecord::Migration[5.2]
     rescue ActiveRecord::StatementInvalid => e
       remove_index :tags, name: 'index_tags_on_name_lower_btree'
       raise CorruptionError, 'index_tags_on_name_lower_btree' if e.is_a?(ActiveRecord::RecordNotUnique)
+
       raise e
     end
 
diff --git a/db/migrate/20220613110834_add_action_to_custom_filters.rb b/db/migrate/20220613110834_add_action_to_custom_filters.rb
index 9427a66fc..c1daf3c94 100644
--- a/db/migrate/20220613110834_add_action_to_custom_filters.rb
+++ b/db/migrate/20220613110834_add_action_to_custom_filters.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 
 class AddActionToCustomFilters < ActiveRecord::Migration[6.1]
diff --git a/db/post_migrate/20200917193528_migrate_notifications_type.rb b/db/post_migrate/20200917193528_migrate_notifications_type.rb
index 88e423084..9dc9ecd48 100644
--- a/db/post_migrate/20200917193528_migrate_notifications_type.rb
+++ b/db/post_migrate/20200917193528_migrate_notifications_type.rb
@@ -4,12 +4,12 @@ class MigrateNotificationsType < ActiveRecord::Migration[5.2]
   disable_ddl_transaction!
 
   TYPES_TO_MIGRATE = {
-    'Mention'       => :mention,
-    'Status'        => :reblog,
-    'Follow'        => :follow,
+    'Mention' => :mention,
+    'Status' => :reblog,
+    'Follow' => :follow,
     'FollowRequest' => :follow_request,
-    'Favourite'     => :favourite,
-    'Poll'          => :poll,
+    'Favourite' => :favourite,
+    'Poll' => :poll,
   }.freeze
 
   def up
diff --git a/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb b/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb
index 7ef0749e5..99c3366a2 100644
--- a/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb
+++ b/db/post_migrate/20220613110802_remove_whole_word_from_custom_filters.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 
 class RemoveWholeWordFromCustomFilters < ActiveRecord::Migration[6.1]
diff --git a/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb b/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb
index 6ed8bcfee..1c366ee53 100644
--- a/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb
+++ b/db/post_migrate/20220613110903_remove_irreversible_from_custom_filters.rb
@@ -1,4 +1,5 @@
 # frozen_string_literal: true
+
 require Rails.root.join('lib', 'mastodon', 'migration_helpers')
 
 class RemoveIrreversibleFromCustomFilters < ActiveRecord::Migration[6.1]
diff --git a/db/post_migrate/20221101190723_backfill_admin_action_logs.rb b/db/post_migrate/20221101190723_backfill_admin_action_logs.rb
index 48ef1e6e3..fa2ddbbca 100644
--- a/db/post_migrate/20221101190723_backfill_admin_action_logs.rb
+++ b/db/post_migrate/20221101190723_backfill_admin_action_logs.rb
@@ -62,7 +62,7 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1]
     # Cannot use usual polymorphic support because of namespacing issues
     belongs_to :status, foreign_key: :target_id
     belongs_to :account, foreign_key: :target_id
-    belongs_to :user, foreign_key: :user_id
+    belongs_to :user
     belongs_to :domain_block, foreign_key: :target_id
     belongs_to :domain_allow, foreign_key: :target_id
     belongs_to :email_domain_block, foreign_key: :target_id
@@ -79,11 +79,13 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1]
     safety_assured do
       AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log|
         next if log.account.nil?
+
         log.update_attribute('human_identifier', log.account.acct)
       end
 
       AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log|
         next if log.user.nil?
+
         log.update_attribute('human_identifier', log.user.account.acct)
         log.update_attribute('route_param', log.user.account_id)
       end
@@ -92,57 +94,68 @@ class BackfillAdminActionLogs < ActiveRecord::Migration[6.1]
 
       AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log|
         next if log.domain_block.nil?
+
         log.update_attribute('human_identifier', log.domain_block.domain)
       end
 
       AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log|
         next if log.domain_allow.nil?
+
         log.update_attribute('human_identifier', log.domain_allow.domain)
       end
 
       AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log|
         next if log.email_domain_block.nil?
+
         log.update_attribute('human_identifier', log.email_domain_block.domain)
       end
 
       AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log|
         next if log.unavailable_domain.nil?
+
         log.update_attribute('human_identifier', log.unavailable_domain.domain)
       end
 
       AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log|
         next if log.status.nil?
+
         log.update_attribute('human_identifier', log.status.account.acct)
         log.update_attribute('permalink', log.status.uri)
       end
 
       AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log|
         next if log.account_warning.nil?
+
         log.update_attribute('human_identifier', log.account_warning.account.acct)
       end
 
       AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log|
         next if log.announcement.nil?
+
         log.update_attribute('human_identifier', log.announcement.text)
       end
 
       AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log|
         next if log.ip_block.nil?
+
         log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}")
       end
 
       AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log|
         next if log.custom_emoji.nil?
+
         log.update_attribute('human_identifier', log.custom_emoji.shortcode)
       end
 
       AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log|
         next if log.canonical_email_block.nil?
+
         log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash)
       end
 
       AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log|
         next if log.appeal.nil?
+
         log.update_attribute('human_identifier', log.appeal.account.acct)
         log.update_attribute('route_param', log.appeal.account_warning_id)
       end
diff --git a/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb b/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb
index 279053ab9..9c7ac7120 100644
--- a/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb
+++ b/db/post_migrate/20221206114142_backfill_admin_action_logs_again.rb
@@ -62,7 +62,7 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1]
     # Cannot use usual polymorphic support because of namespacing issues
     belongs_to :status, foreign_key: :target_id
     belongs_to :account, foreign_key: :target_id
-    belongs_to :user, foreign_key: :user_id
+    belongs_to :user
     belongs_to :domain_block, foreign_key: :target_id
     belongs_to :domain_allow, foreign_key: :target_id
     belongs_to :email_domain_block, foreign_key: :target_id
@@ -79,11 +79,13 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1]
     safety_assured do
       AdminActionLog.includes(:account).where(target_type: 'Account', human_identifier: nil).find_each do |log|
         next if log.account.nil?
+
         log.update_attribute('human_identifier', log.account.acct)
       end
 
       AdminActionLog.includes(user: :account).where(target_type: 'User', human_identifier: nil).find_each do |log|
         next if log.user.nil?
+
         log.update_attribute('human_identifier', log.user.account.acct)
         log.update_attribute('route_param', log.user.account_id)
       end
@@ -92,57 +94,68 @@ class BackfillAdminActionLogsAgain < ActiveRecord::Migration[6.1]
 
       AdminActionLog.includes(:domain_block).where(target_type: 'DomainBlock').find_each do |log|
         next if log.domain_block.nil?
+
         log.update_attribute('human_identifier', log.domain_block.domain)
       end
 
       AdminActionLog.includes(:domain_allow).where(target_type: 'DomainAllow').find_each do |log|
         next if log.domain_allow.nil?
+
         log.update_attribute('human_identifier', log.domain_allow.domain)
       end
 
       AdminActionLog.includes(:email_domain_block).where(target_type: 'EmailDomainBlock').find_each do |log|
         next if log.email_domain_block.nil?
+
         log.update_attribute('human_identifier', log.email_domain_block.domain)
       end
 
       AdminActionLog.includes(:unavailable_domain).where(target_type: 'UnavailableDomain').find_each do |log|
         next if log.unavailable_domain.nil?
+
         log.update_attribute('human_identifier', log.unavailable_domain.domain)
       end
 
       AdminActionLog.includes(status: :account).where(target_type: 'Status', human_identifier: nil).find_each do |log|
         next if log.status.nil?
+
         log.update_attribute('human_identifier', log.status.account.acct)
         log.update_attribute('permalink', log.status.uri)
       end
 
       AdminActionLog.includes(account_warning: :account).where(target_type: 'AccountWarning', human_identifier: nil).find_each do |log|
         next if log.account_warning.nil?
+
         log.update_attribute('human_identifier', log.account_warning.account.acct)
       end
 
       AdminActionLog.includes(:announcement).where(target_type: 'Announcement', human_identifier: nil).find_each do |log|
         next if log.announcement.nil?
+
         log.update_attribute('human_identifier', log.announcement.text)
       end
 
       AdminActionLog.includes(:ip_block).where(target_type: 'IpBlock', human_identifier: nil).find_each do |log|
         next if log.ip_block.nil?
+
         log.update_attribute('human_identifier', "#{log.ip_block.ip}/#{log.ip_block.ip.prefix}")
       end
 
       AdminActionLog.includes(:custom_emoji).where(target_type: 'CustomEmoji', human_identifier: nil).find_each do |log|
         next if log.custom_emoji.nil?
+
         log.update_attribute('human_identifier', log.custom_emoji.shortcode)
       end
 
       AdminActionLog.includes(:canonical_email_block).where(target_type: 'CanonicalEmailBlock', human_identifier: nil).find_each do |log|
         next if log.canonical_email_block.nil?
+
         log.update_attribute('human_identifier', log.canonical_email_block.canonical_email_hash)
       end
 
       AdminActionLog.includes(appeal: :account).where(target_type: 'Appeal', human_identifier: nil).find_each do |log|
         next if log.appeal.nil?
+
         log.update_attribute('human_identifier', log.appeal.account.acct)
         log.update_attribute('route_param', log.appeal.account_warning_id)
       end