Merge tag 'v2.9.2' into instance_only_statuses

This commit is contained in:
Renato "Lond" Cerqueira
2019-06-25 19:44:59 +02:00
534 changed files with 12629 additions and 7877 deletions

View File

@ -8,6 +8,6 @@ class CreateAccountModerationNotes < ActiveRecord::Migration[5.1]
t.timestamps
end
add_foreign_key :account_moderation_notes, :accounts, column: :target_account_id
safety_assured { add_foreign_key :account_moderation_notes, :accounts, column: :target_account_id }
end
end

View File

@ -1,5 +1,5 @@
class AddForeignKeyToAccountModerationNotes < ActiveRecord::Migration[5.1]
def change
add_foreign_key :account_moderation_notes, :accounts
safety_assured { add_foreign_key :account_moderation_notes, :accounts }
end
end

View File

@ -1,6 +1,6 @@
class AddMovedToAccountIdToAccounts < ActiveRecord::Migration[5.1]
def change
add_column :accounts, :moved_to_account_id, :bigint, null: true, default: nil
add_foreign_key :accounts, :accounts, column: :moved_to_account_id, on_delete: :nullify
safety_assured { add_foreign_key :accounts, :accounts, column: :moved_to_account_id, on_delete: :nullify }
end
end

View File

@ -8,7 +8,7 @@ class CreateReportNotes < ActiveRecord::Migration[5.1]
t.timestamps
end
add_foreign_key :report_notes, :reports, column: :report_id, on_delete: :cascade
add_foreign_key :report_notes, :accounts, column: :account_id, on_delete: :cascade
safety_assured { add_foreign_key :report_notes, :reports, column: :report_id, on_delete: :cascade }
safety_assured { add_foreign_key :report_notes, :accounts, column: :account_id, on_delete: :cascade }
end
end

View File

@ -0,0 +1,5 @@
class AddByModeratorToTombstone < ActiveRecord::Migration[5.2]
def change
add_column :tombstones, :by_moderator, :boolean
end
end

View File

@ -0,0 +1,41 @@
class AddSilencedAtSuspendedAtToAccounts < ActiveRecord::Migration[5.2]
class Account < ApplicationRecord
# Dummy class, to make migration possible across version changes
end
class DomainBlock < ApplicationRecord
# Dummy class, to make migration possible across version changes
enum severity: [:silence, :suspend, :noop]
has_many :accounts, foreign_key: :domain, primary_key: :domain
end
def up
add_column :accounts, :silenced_at, :datetime
add_column :accounts, :suspended_at, :datetime
# Record suspend date of blocks and silences for users whose limitations match
# a domain block
DomainBlock.where(severity: [:silence, :suspend]).find_each do |block|
scope = block.accounts
if block.suspend?
block.accounts.where(suspended: true).in_batches.update_all(suspended_at: block.created_at)
else
block.accounts.where(silenced: true).in_batches.update_all(silenced_at: block.created_at)
end
end
# Set dates for accounts which have limitations not related to a domain block
Account.where(suspended: true, suspended_at: nil).in_batches.update_all(suspended_at: Time.now.utc)
Account.where(silenced: true, silenced_at: nil).in_batches.update_all(silenced_at: Time.now.utc)
end
def down
# Block or silence accounts that have a date set
Account.where(suspended: false).where.not(suspended_at: nil).in_batches.update_all(suspended: true)
Account.where(silenced: false).where.not(silenced_at: nil).in_batches.update_all(silenced: true)
remove_column :accounts, :silenced_at
remove_column :accounts, :suspended_at
end
end

View File

@ -0,0 +1,17 @@
class PreserveOldLayoutForExistingUsers < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
# Assume that currently active users are already using the layout that they
# want to use, therefore ensure that it is saved explicitly and not based
# on the to-be-changed default
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
end