mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Add indexes to core models (#2464)
* [claudesquad] update from 'add-indexes-to-core-models' on 18 Jul 25 08:03 EDT * [claudesquad] update from 'add-indexes-to-core-models' on 18 Jul 25 08:09 EDT
This commit is contained in:
parent
8c97c9d31a
commit
d5b147f2cd
2 changed files with 30 additions and 1 deletions
20
db/migrate/20250718120146_add_indexes_to_core_models.rb
Normal file
20
db/migrate/20250718120146_add_indexes_to_core_models.rb
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
class AddIndexesToCoreModels < ActiveRecord::Migration[7.2]
|
||||||
|
def change
|
||||||
|
# Accounts table indexes
|
||||||
|
add_index :accounts, [ :family_id, :status ]
|
||||||
|
add_index :accounts, :status
|
||||||
|
add_index :accounts, :currency
|
||||||
|
|
||||||
|
# Balances table indexes
|
||||||
|
add_index :balances, [ :account_id, :date ], order: { date: :desc }
|
||||||
|
|
||||||
|
# Entries table indexes
|
||||||
|
add_index :entries, [ :account_id, :date ]
|
||||||
|
add_index :entries, :date
|
||||||
|
add_index :entries, :entryable_type
|
||||||
|
add_index :entries, "lower(name)", name: "index_entries_on_lower_name"
|
||||||
|
|
||||||
|
# Transfers table indexes
|
||||||
|
add_index :transfers, :status
|
||||||
|
end
|
||||||
|
end
|
11
db/schema.rb
generated
11
db/schema.rb
generated
|
@ -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[7.2].define(version: 2025_07_10_225721) do
|
ActiveRecord::Schema[7.2].define(version: 2025_07_18_120146) 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 "pgcrypto"
|
enable_extension "pgcrypto"
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -37,11 +37,14 @@ ActiveRecord::Schema[7.2].define(version: 2025_07_10_225721) do
|
||||||
t.string "status", default: "active"
|
t.string "status", default: "active"
|
||||||
t.index ["accountable_id", "accountable_type"], name: "index_accounts_on_accountable_id_and_accountable_type"
|
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 ["accountable_type"], name: "index_accounts_on_accountable_type"
|
||||||
|
t.index ["currency"], name: "index_accounts_on_currency"
|
||||||
t.index ["family_id", "accountable_type"], name: "index_accounts_on_family_id_and_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", "id"], name: "index_accounts_on_family_id_and_id"
|
||||||
|
t.index ["family_id", "status"], name: "index_accounts_on_family_id_and_status"
|
||||||
t.index ["family_id"], name: "index_accounts_on_family_id"
|
t.index ["family_id"], name: "index_accounts_on_family_id"
|
||||||
t.index ["import_id"], name: "index_accounts_on_import_id"
|
t.index ["import_id"], name: "index_accounts_on_import_id"
|
||||||
t.index ["plaid_account_id"], name: "index_accounts_on_plaid_account_id"
|
t.index ["plaid_account_id"], name: "index_accounts_on_plaid_account_id"
|
||||||
|
t.index ["status"], name: "index_accounts_on_status"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "active_storage_attachments", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "active_storage_attachments", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
|
@ -113,6 +116,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_07_10_225721) do
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.decimal "cash_balance", precision: 19, scale: 4, default: "0.0"
|
t.decimal "cash_balance", precision: 19, scale: 4, default: "0.0"
|
||||||
t.index ["account_id", "date", "currency"], name: "index_account_balances_on_account_id_date_currency_unique", unique: true
|
t.index ["account_id", "date", "currency"], name: "index_account_balances_on_account_id_date_currency_unique", unique: true
|
||||||
|
t.index ["account_id", "date"], name: "index_balances_on_account_id_and_date", order: { date: :desc }
|
||||||
t.index ["account_id"], name: "index_balances_on_account_id"
|
t.index ["account_id"], name: "index_balances_on_account_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -215,7 +219,11 @@ ActiveRecord::Schema[7.2].define(version: 2025_07_10_225721) do
|
||||||
t.boolean "excluded", default: false
|
t.boolean "excluded", default: false
|
||||||
t.string "plaid_id"
|
t.string "plaid_id"
|
||||||
t.jsonb "locked_attributes", default: {}
|
t.jsonb "locked_attributes", default: {}
|
||||||
|
t.index "lower((name)::text)", name: "index_entries_on_lower_name"
|
||||||
|
t.index ["account_id", "date"], name: "index_entries_on_account_id_and_date"
|
||||||
t.index ["account_id"], name: "index_entries_on_account_id"
|
t.index ["account_id"], name: "index_entries_on_account_id"
|
||||||
|
t.index ["date"], name: "index_entries_on_date"
|
||||||
|
t.index ["entryable_type"], name: "index_entries_on_entryable_type"
|
||||||
t.index ["import_id"], name: "index_entries_on_import_id"
|
t.index ["import_id"], name: "index_entries_on_import_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -741,6 +749,7 @@ ActiveRecord::Schema[7.2].define(version: 2025_07_10_225721) do
|
||||||
t.index ["inflow_transaction_id", "outflow_transaction_id"], name: "idx_on_inflow_transaction_id_outflow_transaction_id_8cd07a28bd", unique: true
|
t.index ["inflow_transaction_id", "outflow_transaction_id"], name: "idx_on_inflow_transaction_id_outflow_transaction_id_8cd07a28bd", unique: true
|
||||||
t.index ["inflow_transaction_id"], name: "index_transfers_on_inflow_transaction_id"
|
t.index ["inflow_transaction_id"], name: "index_transfers_on_inflow_transaction_id"
|
||||||
t.index ["outflow_transaction_id"], name: "index_transfers_on_outflow_transaction_id"
|
t.index ["outflow_transaction_id"], name: "index_transfers_on_outflow_transaction_id"
|
||||||
|
t.index ["status"], name: "index_transfers_on_status"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
create_table "users", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue