Merge branch 'main' into glitch-soc/merge-upstream

Conflicts:
- `app/views/admin/reports/show.html.haml`:
  Conflicts due to glitch-soc's theming system.
This commit is contained in:
Claire
2022-01-17 10:45:25 +01:00
59 changed files with 1219 additions and 598 deletions

View File

@ -0,0 +1,21 @@
require Rails.root.join('lib', 'mastodon', 'migration_helpers')
class AddCategoryToReports < ActiveRecord::Migration[6.1]
include Mastodon::MigrationHelpers
disable_ddl_transaction!
def up
safety_assured { add_column_with_default :reports, :category, :int, default: 0, allow_null: false }
add_column :reports, :action_taken_at, :datetime
add_column :reports, :rule_ids, :bigint, array: true
safety_assured { execute 'UPDATE reports SET action_taken_at = updated_at WHERE action_taken = TRUE' }
end
def down
safety_assured { execute 'UPDATE reports SET action_taken = TRUE WHERE action_taken_at IS NOT NULL' }
remove_column :reports, :category
remove_column :reports, :action_taken_at
remove_column :reports, :rule_ids
end
end

View File

@ -0,0 +1,6 @@
class AddReportIdToAccountWarnings < ActiveRecord::Migration[6.1]
def change
safety_assured { add_reference :account_warnings, :report, foreign_key: { on_delete: :cascade }, index: false }
add_column :account_warnings, :status_ids, :string, array: true
end
end

View File

@ -0,0 +1,21 @@
class FixAccountWarningActions < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def up
safety_assured do
execute 'UPDATE account_warnings SET action = 1000 WHERE action = 1'
execute 'UPDATE account_warnings SET action = 2000 WHERE action = 2'
execute 'UPDATE account_warnings SET action = 3000 WHERE action = 3'
execute 'UPDATE account_warnings SET action = 4000 WHERE action = 4'
end
end
def down
safety_assured do
execute 'UPDATE account_warnings SET action = 1 WHERE action = 1000'
execute 'UPDATE account_warnings SET action = 2 WHERE action = 2000'
execute 'UPDATE account_warnings SET action = 3 WHERE action = 3000'
execute 'UPDATE account_warnings SET action = 4 WHERE action = 4000'
end
end
end

View File

@ -0,0 +1,7 @@
class AddDeletedAtIndexOnStatuses < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
add_index :statuses, :deleted_at, where: 'deleted_at IS NOT NULL', algorithm: :concurrently
end
end

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
class RemoveActionTakenFromReports < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def change
safety_assured { remove_column :reports, :action_taken, :boolean, default: false, null: false }
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: 2021_12_13_040746) do
ActiveRecord::Schema.define(version: 2022_01_16_202951) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -133,6 +133,8 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
t.text "text", default: "", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "report_id"
t.string "status_ids", array: true
t.index ["account_id"], name: "index_account_warnings_on_account_id"
t.index ["target_account_id"], name: "index_account_warnings_on_target_account_id"
end
@ -747,7 +749,6 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
create_table "reports", force: :cascade do |t|
t.bigint "status_ids", default: [], null: false, array: true
t.text "comment", default: "", null: false
t.boolean "action_taken", default: false, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.bigint "account_id", null: false
@ -756,6 +757,9 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
t.bigint "assigned_account_id"
t.string "uri"
t.boolean "forwarded"
t.integer "category", default: 0, null: false
t.datetime "action_taken_at"
t.bigint "rule_ids", array: true
t.index ["account_id"], name: "index_reports_on_account_id"
t.index ["target_account_id"], name: "index_reports_on_target_account_id"
end
@ -853,6 +857,7 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
t.string "content_type"
t.datetime "deleted_at"
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)"
t.index ["id", "account_id"], name: "index_statuses_local_20190824", order: { id: :desc }, where: "((local OR (uri IS NULL)) AND (deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
t.index ["id", "account_id"], name: "index_statuses_public_20200119", order: { id: :desc }, where: "((deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
@ -1010,6 +1015,7 @@ ActiveRecord::Schema.define(version: 2021_12_13_040746) do
add_foreign_key "account_statuses_cleanup_policies", "accounts", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", column: "target_account_id", on_delete: :cascade
add_foreign_key "account_warnings", "accounts", on_delete: :nullify
add_foreign_key "account_warnings", "reports", on_delete: :cascade
add_foreign_key "accounts", "accounts", column: "moved_to_account_id", on_delete: :nullify
add_foreign_key "admin_action_logs", "accounts", on_delete: :cascade
add_foreign_key "announcement_mutes", "accounts", on_delete: :cascade