forked from cybrespace/mastodon
Add missing indices for ON DELETE CASCADE constraints (#8332)
Fix #8327
This commit is contained in:
parent
513cb20b75
commit
025a06d322
|
@ -0,0 +1,16 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddForeignKeyIndices < ActiveRecord::Migration[5.2]
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def change
|
||||||
|
add_index :follows, :target_account_id, algorithm: :concurrently
|
||||||
|
add_index :blocks, :target_account_id, algorithm: :concurrently
|
||||||
|
add_index :mutes, :target_account_id, algorithm: :concurrently
|
||||||
|
add_index :notifications, :from_account_id, algorithm: :concurrently
|
||||||
|
add_index :accounts, :moved_to_account_id, algorithm: :concurrently
|
||||||
|
add_index :statuses, :in_reply_to_account_id, algorithm: :concurrently
|
||||||
|
add_index :session_activations, :access_token_id, algorithm: :concurrently
|
||||||
|
add_index :oauth_access_grants, :resource_owner_id, algorithm: :concurrently
|
||||||
|
end
|
||||||
|
end
|
10
db/schema.rb
10
db/schema.rb
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
ActiveRecord::Schema.define(version: 2018_08_20_232245) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -88,6 +88,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.string "actor_type"
|
t.string "actor_type"
|
||||||
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 "(((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 "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"
|
||||||
t.index ["uri"], name: "index_accounts_on_uri"
|
t.index ["uri"], name: "index_accounts_on_uri"
|
||||||
t.index ["url"], name: "index_accounts_on_url"
|
t.index ["url"], name: "index_accounts_on_url"
|
||||||
end
|
end
|
||||||
|
@ -122,6 +123,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.bigint "target_account_id", null: false
|
t.bigint "target_account_id", null: false
|
||||||
t.string "uri"
|
t.string "uri"
|
||||||
t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
|
t.index ["account_id", "target_account_id"], name: "index_blocks_on_account_id_and_target_account_id", unique: true
|
||||||
|
t.index ["target_account_id"], name: "index_blocks_on_target_account_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "conversation_mutes", force: :cascade do |t|
|
create_table "conversation_mutes", force: :cascade do |t|
|
||||||
|
@ -209,6 +211,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.boolean "show_reblogs", default: true, null: false
|
t.boolean "show_reblogs", default: true, null: false
|
||||||
t.string "uri"
|
t.string "uri"
|
||||||
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
|
t.index ["account_id", "target_account_id"], name: "index_follows_on_account_id_and_target_account_id", unique: true
|
||||||
|
t.index ["target_account_id"], name: "index_follows_on_target_account_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "identities", id: :serial, force: :cascade do |t|
|
create_table "identities", id: :serial, force: :cascade do |t|
|
||||||
|
@ -297,6 +300,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.bigint "target_account_id", null: false
|
t.bigint "target_account_id", null: false
|
||||||
t.boolean "hide_notifications", default: true, 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 ["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
|
end
|
||||||
|
|
||||||
create_table "notifications", force: :cascade do |t|
|
create_table "notifications", force: :cascade do |t|
|
||||||
|
@ -309,6 +313,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
|
t.index ["account_id", "activity_id", "activity_type"], name: "account_activity", unique: true
|
||||||
t.index ["account_id", "id"], name: "index_notifications_on_account_id_and_id", order: { id: :desc }
|
t.index ["account_id", "id"], name: "index_notifications_on_account_id_and_id", order: { id: :desc }
|
||||||
t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
|
t.index ["activity_id", "activity_type"], name: "index_notifications_on_activity_id_and_activity_type"
|
||||||
|
t.index ["from_account_id"], name: "index_notifications_on_from_account_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "oauth_access_grants", force: :cascade do |t|
|
create_table "oauth_access_grants", force: :cascade do |t|
|
||||||
|
@ -320,6 +325,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.string "scopes"
|
t.string "scopes"
|
||||||
t.bigint "application_id", null: false
|
t.bigint "application_id", null: false
|
||||||
t.bigint "resource_owner_id", null: false
|
t.bigint "resource_owner_id", null: false
|
||||||
|
t.index ["resource_owner_id"], name: "index_oauth_access_grants_on_resource_owner_id"
|
||||||
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -423,6 +429,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.bigint "access_token_id"
|
t.bigint "access_token_id"
|
||||||
t.bigint "user_id", null: false
|
t.bigint "user_id", null: false
|
||||||
t.bigint "web_push_subscription_id"
|
t.bigint "web_push_subscription_id"
|
||||||
|
t.index ["access_token_id"], name: "index_session_activations_on_access_token_id"
|
||||||
t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
|
t.index ["session_id"], name: "index_session_activations_on_session_id", unique: true
|
||||||
t.index ["user_id"], name: "index_session_activations_on_user_id"
|
t.index ["user_id"], name: "index_session_activations_on_user_id"
|
||||||
end
|
end
|
||||||
|
@ -486,6 +493,7 @@ ActiveRecord::Schema.define(version: 2018_08_14_171349) do
|
||||||
t.bigint "application_id"
|
t.bigint "application_id"
|
||||||
t.bigint "in_reply_to_account_id"
|
t.bigint "in_reply_to_account_id"
|
||||||
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
|
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20180106", order: { id: :desc }
|
||||||
|
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id"
|
||||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id"
|
||||||
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
|
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
|
||||||
t.index ["uri"], name: "index_statuses_on_uri", unique: true
|
t.index ["uri"], name: "index_statuses_on_uri", unique: true
|
||||||
|
|
Loading…
Reference in New Issue