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

View File

@ -0,0 +1,45 @@
# frozen_string_literal: true
class RemoveSuspendedSilencedAccountFields < 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
disable_ddl_transaction!
def up
# 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)
safety_assured do
remove_column :accounts, :suspended, :boolean, null: false, default: false
remove_column :accounts, :silenced, :boolean, null: false, default: false
end
end
def down
safety_assured do
add_column :accounts, :suspended, :boolean, null: false, default: false
add_column :accounts, :silenced, :boolean, null: false, default: false
end
end
end

View File

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_05_19_130537) do
ActiveRecord::Schema.define(version: 2019_05_29_143559) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -131,8 +131,6 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
t.datetime "header_updated_at"
t.string "avatar_remote_url"
t.datetime "subscription_expires_at"
t.boolean "silenced", default: false, null: false
t.boolean "suspended", default: false, null: false
t.boolean "locked", default: false, null: false
t.string "header_remote_url", default: "", null: false
t.datetime "last_webfingered_at"
@ -148,6 +146,8 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
t.string "actor_type"
t.boolean "discoverable"
t.string "also_known_as", array: true
t.datetime "silenced_at"
t.datetime "suspended_at"
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower", unique: true
t.index ["moved_to_account_id"], name: "index_accounts_on_moved_to_account_id"
@ -382,9 +382,9 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
create_table "mutes", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "hide_notifications", default: true, null: false
t.bigint "account_id", null: false
t.bigint "target_account_id", null: false
t.boolean "hide_notifications", default: true, null: false
t.index ["account_id", "target_account_id"], name: "index_mutes_on_account_id_and_target_account_id", unique: true
t.index ["target_account_id"], name: "index_mutes_on_target_account_id"
end
@ -677,6 +677,7 @@ ActiveRecord::Schema.define(version: 2019_05_19_130537) do
t.string "uri", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "by_moderator"
t.index ["account_id"], name: "index_tombstones_on_account_id"
t.index ["uri"], name: "index_tombstones_on_uri"
end