Skip to content

Commit

Permalink
funds-manager: migrations: Add gas_wallets table
Browse files Browse the repository at this point in the history
  • Loading branch information
joeykraut committed Aug 1, 2024
1 parent 9b9c770 commit 390b991
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
14 changes: 14 additions & 0 deletions funds-manager/funds-manager-server/src/db/models.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#![allow(missing_docs)]
#![allow(trivial_bounds)]

use std::time::SystemTime;

use bigdecimal::BigDecimal;
use diesel::prelude::*;
use num_bigint::BigInt;
Expand Down Expand Up @@ -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: i32,
pub address: String,
pub peer_id: String,
pub active: bool,
pub created_at: SystemTime,
}
11 changes: 11 additions & 0 deletions funds-manager/funds-manager-server/src/db/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ diesel::table! {
}
}

diesel::table! {
gas_wallets (id) {
id -> Int4,
address -> Text,
peer_id -> Text,
active -> Bool,
created_at -> Timestamp,
}
}

diesel::table! {
hot_wallets (id) {
id -> Uuid,
Expand Down Expand Up @@ -39,6 +49,7 @@ diesel::table! {

diesel::allow_tables_to_appear_in_same_query!(
fees,
gas_wallets,
hot_wallets,
indexing_metadata,
renegade_wallets,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Drop the gas_wallets table
DROP TABLE IF EXISTS gas_wallets;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Create a table to store gas wallets
CREATE TABLE gas_wallets (
id SERIAL PRIMARY KEY,
address TEXT NOT NULL UNIQUE,
peer_id TEXT NOT NULL,
active BOOLEAN NOT NULL DEFAULT FALSE,
created_at TIMESTAMP NOT NULL DEFAULT NOW()
);

0 comments on commit 390b991

Please sign in to comment.