mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Plaid sync domain improvements (#2267)
Breaks our Plaid sync process out into more manageable classes. Notably, this moves the sync process to a distinct, 2-step flow: 1. Import stage - we first make API calls and import Plaid data to "mirror" tables 2. Processing stage - read the raw data, apply business rules, build internal domain models and sync balances This provides several benefits: - Plaid syncs can now be "replayed" without fetching API data again - Mirror tables provide better audit and debugging capabilities - Eliminates the "all or nothing" sync behavior that is currently in place, which is brittle
This commit is contained in:
parent
5c82af0e8c
commit
03a146222d
72 changed files with 3763 additions and 706 deletions
22
db/schema.rb
generated
22
db/schema.rb
generated
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_05_22_201031) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2025_05_23_131455) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
|
@ -420,23 +420,28 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_22_201031) do
|
|||
|
||||
create_table "plaid_accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "plaid_item_id", null: false
|
||||
t.string "plaid_id"
|
||||
t.string "plaid_type"
|
||||
t.string "plaid_id", null: false
|
||||
t.string "plaid_type", null: false
|
||||
t.string "plaid_subtype"
|
||||
t.decimal "current_balance", precision: 19, scale: 4
|
||||
t.decimal "available_balance", precision: 19, scale: 4
|
||||
t.string "currency"
|
||||
t.string "name"
|
||||
t.string "currency", null: false
|
||||
t.string "name", null: false
|
||||
t.string "mask"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.jsonb "raw_payload", default: {}
|
||||
t.jsonb "raw_transactions_payload", default: {}
|
||||
t.jsonb "raw_investments_payload", default: {}
|
||||
t.jsonb "raw_liabilities_payload", default: {}
|
||||
t.index ["plaid_id"], name: "index_plaid_accounts_on_plaid_id", unique: true
|
||||
t.index ["plaid_item_id"], name: "index_plaid_accounts_on_plaid_item_id"
|
||||
end
|
||||
|
||||
create_table "plaid_items", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "family_id", null: false
|
||||
t.string "access_token"
|
||||
t.string "plaid_id"
|
||||
t.string "plaid_id", null: false
|
||||
t.string "name"
|
||||
t.string "next_cursor"
|
||||
t.boolean "scheduled_for_deletion", default: false
|
||||
|
@ -449,7 +454,10 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_22_201031) do
|
|||
t.string "institution_id"
|
||||
t.string "institution_color"
|
||||
t.string "status", default: "good", null: false
|
||||
t.jsonb "raw_payload", default: {}
|
||||
t.jsonb "raw_institution_payload", default: {}
|
||||
t.index ["family_id"], name: "index_plaid_items_on_family_id"
|
||||
t.index ["plaid_id"], name: "index_plaid_items_on_plaid_id", unique: true
|
||||
end
|
||||
|
||||
create_table "properties", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
|
@ -637,8 +645,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_05_22_201031) do
|
|||
t.uuid "category_id"
|
||||
t.uuid "merchant_id"
|
||||
t.jsonb "locked_attributes", default: {}
|
||||
t.string "plaid_category"
|
||||
t.string "plaid_category_detailed"
|
||||
t.index ["category_id"], name: "index_transactions_on_category_id"
|
||||
t.index ["merchant_id"], name: "index_transactions_on_merchant_id"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue