From 68ffa36f7a49ce546bc0fca7e300a5bd341b68b8 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 9 Dec 2023 22:27:20 +0100 Subject: [PATCH 1/2] Add index for `user_bans.user_id` --- .../20231209212629_add_index_on_user_bans_user_id.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 db/migrate/20231209212629_add_index_on_user_bans_user_id.rb diff --git a/db/migrate/20231209212629_add_index_on_user_bans_user_id.rb b/db/migrate/20231209212629_add_index_on_user_bans_user_id.rb new file mode 100644 index 00000000..cb6101d9 --- /dev/null +++ b/db/migrate/20231209212629_add_index_on_user_bans_user_id.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddIndexOnUserBansUserId < ActiveRecord::Migration[7.0] + def change + add_index :user_bans, :user_id + end +end From 49d49e4aa4c17f85611860389d31c83d088eda27 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 9 Dec 2023 22:42:44 +0100 Subject: [PATCH 2/2] Update schema.rb --- db/schema.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 9578bac6..0bc10764 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_11_07_200845) do +ActiveRecord::Schema[7.0].define(version: 2023_12_09_212629) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -28,11 +28,11 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_07_200845) do end create_table "anonymous_blocks", force: :cascade do |t| - t.bigint "user_id" t.string "identifier" - t.bigint "question_id" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.bigint "question_id" + t.bigint "user_id" t.bigint "target_user_id" t.index ["identifier"], name: "index_anonymous_blocks_on_identifier" t.index ["question_id"], name: "index_anonymous_blocks_on_question_id" @@ -95,10 +95,10 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_07_200845) do end create_table "mute_rules", id: :bigint, default: -> { "gen_timestamp_id('mute_rules'::text)" }, force: :cascade do |t| - t.bigint "user_id" t.string "muted_phrase" t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false + t.bigint "user_id" t.index ["user_id"], name: "index_mute_rules_on_user_id" end @@ -183,7 +183,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_07_200845) do t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" - t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id" + t.index ["resource_type", "resource_id"], name: "index_roles_on_resource" end create_table "rpush_apps", force: :cascade do |t| @@ -308,6 +308,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_11_07_200845) do t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.index ["expires_at"], name: "index_user_bans_on_expires_at", order: :desc + t.index ["user_id"], name: "index_user_bans_on_user_id" end create_table "users", id: :bigint, default: -> { "gen_timestamp_id('users'::text)" }, force: :cascade do |t|