mirror of
https://github.com/we-promise/sure
synced 2026-04-25 17:15:07 +02:00
Mercury integration (#723)
* Initial mercury impl * FIX both mercury and generator class * Finish mercury integration and provider generator * Fix schema * Fix linter and tags * Update routes.rb * Avoid schema drift --------- Signed-off-by: soky srm <sokysrm@gmail.com> Co-authored-by: Juan José Mata <juanjo.mata@gmail.com>
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
class CreateMercuryItemsAndAccounts < ActiveRecord::Migration[7.2]
|
||||
def change
|
||||
# Create provider items table (stores per-family connection credentials)
|
||||
create_table :mercury_items, id: :uuid do |t|
|
||||
t.references :family, null: false, foreign_key: true, type: :uuid
|
||||
t.string :name
|
||||
|
||||
# Institution metadata
|
||||
t.string :institution_id
|
||||
t.string :institution_name
|
||||
t.string :institution_domain
|
||||
t.string :institution_url
|
||||
t.string :institution_color
|
||||
|
||||
# Status and lifecycle
|
||||
t.string :status, default: "good"
|
||||
t.boolean :scheduled_for_deletion, default: false
|
||||
t.boolean :pending_account_setup, default: false
|
||||
|
||||
# Sync settings
|
||||
t.datetime :sync_start_date
|
||||
|
||||
# Raw data storage
|
||||
t.jsonb :raw_payload
|
||||
t.jsonb :raw_institution_payload
|
||||
|
||||
# Provider-specific credential fields
|
||||
t.text :token
|
||||
t.string :base_url
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :mercury_items, :status
|
||||
|
||||
# Create provider accounts table (stores individual account data from provider)
|
||||
create_table :mercury_accounts, id: :uuid do |t|
|
||||
t.references :mercury_item, null: false, foreign_key: true, type: :uuid
|
||||
|
||||
# Account identification
|
||||
t.string :name
|
||||
t.string :account_id, null: false
|
||||
|
||||
# Account details
|
||||
t.string :currency
|
||||
t.decimal :current_balance, precision: 19, scale: 4
|
||||
t.string :account_status
|
||||
t.string :account_type
|
||||
t.string :provider
|
||||
|
||||
# Metadata and raw data
|
||||
t.jsonb :institution_metadata
|
||||
t.jsonb :raw_payload
|
||||
t.jsonb :raw_transactions_payload
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :mercury_accounts, :account_id, unique: true
|
||||
end
|
||||
end
|
||||
44
db/schema.rb
generated
44
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: 2026_01_19_005756) do
|
||||
ActiveRecord::Schema[7.2].define(version: 2026_01_21_101345) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pgcrypto"
|
||||
enable_extension "plpgsql"
|
||||
@@ -778,6 +778,46 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_19_005756) do
|
||||
t.index ["type"], name: "index_merchants_on_type"
|
||||
end
|
||||
|
||||
create_table "mercury_accounts", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "mercury_item_id", null: false
|
||||
t.string "name"
|
||||
t.string "account_id", null: false
|
||||
t.string "currency"
|
||||
t.decimal "current_balance", precision: 19, scale: 4
|
||||
t.string "account_status"
|
||||
t.string "account_type"
|
||||
t.string "provider"
|
||||
t.jsonb "institution_metadata"
|
||||
t.jsonb "raw_payload"
|
||||
t.jsonb "raw_transactions_payload"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id"], name: "index_mercury_accounts_on_account_id", unique: true
|
||||
t.index ["mercury_item_id"], name: "index_mercury_accounts_on_mercury_item_id"
|
||||
end
|
||||
|
||||
create_table "mercury_items", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "family_id", null: false
|
||||
t.string "name"
|
||||
t.string "institution_id"
|
||||
t.string "institution_name"
|
||||
t.string "institution_domain"
|
||||
t.string "institution_url"
|
||||
t.string "institution_color"
|
||||
t.string "status", default: "good"
|
||||
t.boolean "scheduled_for_deletion", default: false
|
||||
t.boolean "pending_account_setup", default: false
|
||||
t.datetime "sync_start_date"
|
||||
t.jsonb "raw_payload"
|
||||
t.jsonb "raw_institution_payload"
|
||||
t.text "token"
|
||||
t.string "base_url"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["family_id"], name: "index_mercury_items_on_family_id"
|
||||
t.index ["status"], name: "index_mercury_items_on_status"
|
||||
end
|
||||
|
||||
create_table "messages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
||||
t.uuid "chat_id", null: false
|
||||
t.string "type", null: false
|
||||
@@ -1365,6 +1405,8 @@ ActiveRecord::Schema[7.2].define(version: 2026_01_19_005756) do
|
||||
add_foreign_key "lunchflow_accounts", "lunchflow_items"
|
||||
add_foreign_key "lunchflow_items", "families"
|
||||
add_foreign_key "merchants", "families"
|
||||
add_foreign_key "mercury_accounts", "mercury_items"
|
||||
add_foreign_key "mercury_items", "families"
|
||||
add_foreign_key "messages", "chats"
|
||||
add_foreign_key "mobile_devices", "users"
|
||||
add_foreign_key "oauth_access_grants", "oauth_applications", column: "application_id"
|
||||
|
||||
Reference in New Issue
Block a user