1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-19 05:09:38 +02:00

Account indexes to address some performance issues

This commit is contained in:
Josh Pigford 2024-10-17 15:45:13 -05:00
parent d4bfcfb6f4
commit 75a390f03e
2 changed files with 39 additions and 2 deletions

View file

@ -0,0 +1,7 @@
class AddAccountsIndexes < ActiveRecord::Migration[7.2]
def change
add_index :accounts, [ :family_id, :accountable_type ]
add_index :accounts, [ :accountable_id, :accountable_type ]
add_index :accounts, [ :family_id, :id ]
end
end

34
db/schema.rb generated
View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.2].define(version: 2024_10_09_132959) do
ActiveRecord::Schema[7.2].define(version: 2024_10_17_204250) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
@ -120,9 +120,12 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_09_132959) do
t.boolean "is_active", default: true, null: false
t.date "last_sync_date"
t.uuid "institution_id"
t.virtual "classification", type: :string, as: "\nCASE\n WHEN ((accountable_type)::text = ANY ((ARRAY['Loan'::character varying, 'CreditCard'::character varying, 'OtherLiability'::character varying])::text[])) THEN 'liability'::text\n ELSE 'asset'::text\nEND", stored: true
t.virtual "classification", type: :string, as: "\nCASE\n WHEN ((accountable_type)::text = ANY (ARRAY[('Loan'::character varying)::text, ('CreditCard'::character varying)::text, ('OtherLiability'::character varying)::text])) THEN 'liability'::text\n ELSE 'asset'::text\nEND", stored: true
t.uuid "import_id"
t.index ["accountable_id", "accountable_type"], name: "index_accounts_on_accountable_id_and_accountable_type"
t.index ["accountable_type"], name: "index_accounts_on_accountable_type"
t.index ["family_id", "accountable_type"], name: "index_accounts_on_family_id_and_accountable_type"
t.index ["family_id", "id"], name: "index_accounts_on_family_id_and_id"
t.index ["family_id"], name: "index_accounts_on_family_id"
t.index ["import_id"], name: "index_accounts_on_import_id"
t.index ["institution_id"], name: "index_accounts_on_institution_id"
@ -313,6 +316,29 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_09_132959) do
t.index ["scheduled_at"], name: "index_good_jobs_on_scheduled_at", where: "(finished_at IS NULL)"
end
create_table "impersonation_session_logs", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "impersonation_session_id", null: false
t.string "controller"
t.string "action"
t.text "path"
t.string "method"
t.string "ip_address"
t.text "user_agent"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["impersonation_session_id"], name: "index_impersonation_session_logs_on_impersonation_session_id"
end
create_table "impersonation_sessions", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.uuid "impersonator_id", null: false
t.uuid "impersonated_id", null: false
t.string "status", default: "pending", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["impersonated_id"], name: "index_impersonation_sessions_on_impersonated_id"
t.index ["impersonator_id"], name: "index_impersonation_sessions_on_impersonator_id"
end
create_table "import_mappings", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "type", null: false
t.string "key"
@ -509,6 +535,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_09_132959) do
t.string "last_alerted_upgrade_commit_sha"
t.enum "role", default: "member", null: false, enum_type: "user_role"
t.boolean "active", default: true, null: false
t.boolean "super_admin", default: false
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["family_id"], name: "index_users_on_family_id"
end
@ -539,6 +566,9 @@ ActiveRecord::Schema[7.2].define(version: 2024_10_09_132959) do
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
add_foreign_key "categories", "families"
add_foreign_key "impersonation_session_logs", "impersonation_sessions"
add_foreign_key "impersonation_sessions", "users", column: "impersonated_id"
add_foreign_key "impersonation_sessions", "users", column: "impersonator_id"
add_foreign_key "import_rows", "imports"
add_foreign_key "imports", "families"
add_foreign_key "institutions", "families"