Skip to content

Commit

Permalink
events-collector: events-collector-server: add dimension table schema…
Browse files Browse the repository at this point in the history
…s & migrations
  • Loading branch information
akirillo committed Sep 11, 2024
1 parent e1e6f7d commit 59649c6
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 0 deletions.
50 changes: 50 additions & 0 deletions events-collector/events-collector-server/src/db/schema.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
// @generated automatically by Diesel CLI.

diesel::table! {
assets (mint) {
mint -> Text,
ticker -> Text,
name -> Text,
decimals -> Int4,
}
}

diesel::table! {
balances (wallet_id, mint) {
wallet_id -> Uuid,
mint -> Text,
amount -> Numeric,
relayer_fee -> Numeric,
protocol_fee -> Numeric,
}
}

diesel::table! {
deposits (event_id) {
event_id -> Uuid,
Expand Down Expand Up @@ -68,6 +87,22 @@ diesel::table! {
}
}

diesel::table! {
orders (order_id) {
order_id -> Uuid,
wallet_id -> Uuid,
base_mint -> Text,
quote_mint -> Text,
is_sell -> Bool,
amount -> Numeric,
amount_filled -> Numeric,
created_at -> Timestamp,
last_updated_at -> Timestamp,
last_filled_at -> Timestamp,
ts -> Timestamp,
}
}

diesel::table! {
price_updates (event_id) {
event_id -> Uuid,
Expand All @@ -87,6 +122,17 @@ diesel::table! {
}
}

diesel::table! {
wallets (wallet_id) {
wallet_id -> Uuid,
created_at -> Timestamp,
last_updated_at -> Timestamp,
is_protocol_wallet -> Bool,
is_relayer_wallet -> Bool,
is_quoter_wallet -> Bool,
}
}

diesel::table! {
withdrawals (event_id) {
event_id -> Uuid,
Expand All @@ -98,13 +144,17 @@ diesel::table! {
}

diesel::allow_tables_to_appear_in_same_query!(
assets,
balances,
deposits,
fee_collections,
fee_payments,
matches,
order_cancellations,
order_placements,
orders,
price_updates,
wallet_creations,
wallets,
withdrawals,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- This file should undo anything in `up.sql`









DROP TABLE IF EXISTS "wallets";
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Your SQL goes here









CREATE TABLE "wallets"(
"wallet_id" UUID NOT NULL PRIMARY KEY,
"created_at" TIMESTAMP NOT NULL,
"last_updated_at" TIMESTAMP NOT NULL,
"is_protocol_wallet" BOOL NOT NULL,
"is_relayer_wallet" BOOL NOT NULL,
"is_quoter_wallet" BOOL NOT NULL
);

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
-- This file should undo anything in `up.sql`










DROP TABLE IF EXISTS "balances";
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Your SQL goes here










CREATE TABLE "balances"(
"wallet_id" UUID NOT NULL,
"mint" TEXT NOT NULL,
"amount" NUMERIC NOT NULL,
"relayer_fee" NUMERIC NOT NULL,
"protocol_fee" NUMERIC NOT NULL,
PRIMARY KEY("wallet_id", "mint")
);

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- This file should undo anything in `up.sql`











DROP TABLE IF EXISTS "orders";
26 changes: 26 additions & 0 deletions events-collector/migrations/2024-09-11-045833_create_orders/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- Your SQL goes here











CREATE TABLE "orders"(
"order_id" UUID NOT NULL PRIMARY KEY,
"wallet_id" UUID NOT NULL,
"base_mint" TEXT NOT NULL,
"quote_mint" TEXT NOT NULL,
"is_sell" BOOL NOT NULL,
"amount" NUMERIC NOT NULL,
"amount_filled" NUMERIC NOT NULL,
"created_at" TIMESTAMP NOT NULL,
"last_updated_at" TIMESTAMP NOT NULL,
"last_filled_at" TIMESTAMP NOT NULL,
"ts" TIMESTAMP NOT NULL
);

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-- This file should undo anything in `up.sql`












DROP TABLE IF EXISTS "assets";
20 changes: 20 additions & 0 deletions events-collector/migrations/2024-09-11-050357_create_assets/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Your SQL goes here












CREATE TABLE "assets"(
"mint" TEXT NOT NULL PRIMARY KEY,
"ticker" TEXT NOT NULL,
"name" TEXT NOT NULL,
"decimals" INT4 NOT NULL
);

0 comments on commit 59649c6

Please sign in to comment.