diff --git a/funds-manager/funds-manager-server/src/db/models.rs b/funds-manager/funds-manager-server/src/db/models.rs index ffcd650..fd7410c 100644 --- a/funds-manager/funds-manager-server/src/db/models.rs +++ b/funds-manager/funds-manager-server/src/db/models.rs @@ -1,6 +1,8 @@ #![allow(missing_docs)] #![allow(trivial_bounds)] +use std::time::SystemTime; + use bigdecimal::BigDecimal; use diesel::prelude::*; use num_bigint::BigInt; @@ -100,3 +102,15 @@ impl HotWallet { HotWallet { id: Uuid::new_v4(), secret_id, vault, address, internal_wallet_id } } } + +/// A gas wallet's metadata +#[derive(Clone, Queryable, Selectable, Insertable)] +#[diesel(table_name = crate::db::schema::gas_wallets)] +#[diesel(check_for_backend(diesel::pg::Pg))] +pub struct GasWallet { + pub id: Uuid, + pub address: String, + pub peer_id: Option, + pub active: bool, + pub created_at: SystemTime, +} diff --git a/funds-manager/funds-manager-server/src/db/schema.rs b/funds-manager/funds-manager-server/src/db/schema.rs index b1b86dd..3d49041 100644 --- a/funds-manager/funds-manager-server/src/db/schema.rs +++ b/funds-manager/funds-manager-server/src/db/schema.rs @@ -12,6 +12,16 @@ diesel::table! { } } +diesel::table! { + gas_wallets (id) { + id -> Uuid, + address -> Text, + peer_id -> Nullable, + active -> Bool, + created_at -> Timestamp, + } +} + diesel::table! { hot_wallets (id) { id -> Uuid, @@ -39,6 +49,7 @@ diesel::table! { diesel::allow_tables_to_appear_in_same_query!( fees, + gas_wallets, hot_wallets, indexing_metadata, renegade_wallets, diff --git a/funds-manager/migrations/2024-08-01-214330_add_gas_wallets_table/down.sql b/funds-manager/migrations/2024-08-01-214330_add_gas_wallets_table/down.sql new file mode 100644 index 0000000..a5072f3 --- /dev/null +++ b/funds-manager/migrations/2024-08-01-214330_add_gas_wallets_table/down.sql @@ -0,0 +1,2 @@ +-- Drop the gas_wallets table +DROP TABLE IF EXISTS gas_wallets; \ No newline at end of file diff --git a/funds-manager/migrations/2024-08-01-214330_add_gas_wallets_table/up.sql b/funds-manager/migrations/2024-08-01-214330_add_gas_wallets_table/up.sql new file mode 100644 index 0000000..04d8f8e --- /dev/null +++ b/funds-manager/migrations/2024-08-01-214330_add_gas_wallets_table/up.sql @@ -0,0 +1,8 @@ +-- Create a table to store gas wallets +CREATE TABLE gas_wallets ( + id UUID PRIMARY KEY, + address TEXT NOT NULL UNIQUE, + peer_id TEXT, + active BOOLEAN NOT NULL DEFAULT FALSE, + created_at TIMESTAMP NOT NULL DEFAULT NOW() +); \ No newline at end of file