mirror of
https://github.com/cf-sonr/radar.git
synced 2026-01-12 02:59:13 +00:00
feat: implement account, profile, network, and activity management
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
1
internal/migrations/001_accounts_table.down.sql
Normal file
1
internal/migrations/001_accounts_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE accounts;
|
||||
30
internal/migrations/001_accounts_table.up.sql
Normal file
30
internal/migrations/001_accounts_table.up.sql
Normal file
@@ -0,0 +1,30 @@
|
||||
-- Accounts represent blockchain accounts
|
||||
CREATE TABLE accounts (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
number INTEGER NOT NULL,
|
||||
sequence INTEGER NOT NULL DEFAULT 0,
|
||||
address TEXT NOT NULL UNIQUE,
|
||||
public_key TEXT NOT NULL CHECK(json_valid(public_key)),
|
||||
chain_id TEXT NOT NULL,
|
||||
block_created INTEGER NOT NULL,
|
||||
controller TEXT NOT NULL,
|
||||
label TEXT NOT NULL,
|
||||
handle TEXT NOT NULL,
|
||||
is_subsidiary BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_subsidiary IN (0,1)),
|
||||
is_validator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_validator IN (0,1)),
|
||||
is_delegator BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_delegator IN (0,1)),
|
||||
is_accountable BOOLEAN NOT NULL DEFAULT TRUE CHECK(is_accountable IN (0,1))
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX idx_accounts_address ON accounts(address);
|
||||
CREATE INDEX idx_accounts_chain_id ON accounts(chain_id);
|
||||
CREATE INDEX idx_accounts_block_created ON accounts(block_created);
|
||||
CREATE INDEX idx_accounts_label ON accounts(label);
|
||||
CREATE INDEX idx_accounts_controller ON accounts(controller);
|
||||
CREATE INDEX idx_accounts_deleted_at ON accounts(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/002_credentials_table.down.sql
Normal file
1
internal/migrations/002_credentials_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE credentials;
|
||||
19
internal/migrations/002_credentials_table.up.sql
Normal file
19
internal/migrations/002_credentials_table.up.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Credentials store WebAuthn credentials
|
||||
CREATE TABLE credentials (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
handle TEXT NOT NULL,
|
||||
credential_id TEXT NOT NULL UNIQUE,
|
||||
authenticator_attachment TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
type TEXT NOT NULL,
|
||||
transports TEXT NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_credentials_handle ON credentials(handle);
|
||||
CREATE INDEX idx_credentials_origin ON credentials(origin);
|
||||
CREATE INDEX idx_credentials_deleted_at ON credentials(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/003_profiles_table.down.sql
Normal file
1
internal/migrations/003_profiles_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE profiles;
|
||||
18
internal/migrations/003_profiles_table.up.sql
Normal file
18
internal/migrations/003_profiles_table.up.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- Profiles represent user identities
|
||||
CREATE TABLE profiles (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
address TEXT NOT NULL,
|
||||
handle TEXT NOT NULL UNIQUE,
|
||||
origin TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
UNIQUE(address, origin)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_profiles_handle ON profiles(handle);
|
||||
CREATE INDEX idx_profiles_address ON profiles(address);
|
||||
CREATE INDEX idx_profiles_deleted_at ON profiles(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/004_vaults_table.down.sql
Normal file
1
internal/migrations/004_vaults_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE vaults;
|
||||
19
internal/migrations/004_vaults_table.up.sql
Normal file
19
internal/migrations/004_vaults_table.up.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Vaults store encrypted data
|
||||
CREATE TABLE vaults (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
handle TEXT NOT NULL,
|
||||
origin TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
cid TEXT NOT NULL UNIQUE,
|
||||
config TEXT NOT NULL CHECK(json_valid(config)),
|
||||
session_id TEXT NOT NULL,
|
||||
redirect_uri TEXT NOT NULL
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX idx_vaults_handle ON vaults(handle);
|
||||
CREATE INDEX idx_vaults_session_id ON vaults(session_id);
|
||||
CREATE INDEX idx_vaults_deleted_at ON vaults(deleted_at)
|
||||
1
internal/migrations/005_assets_table.down.sql
Normal file
1
internal/migrations/005_assets_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE assets;
|
||||
21
internal/migrations/005_assets_table.up.sql
Normal file
21
internal/migrations/005_assets_table.up.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Assets represent tokens and coins
|
||||
CREATE TABLE assets (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
name TEXT NOT NULL,
|
||||
symbol TEXT NOT NULL,
|
||||
decimals INTEGER NOT NULL CHECK(decimals >= 0),
|
||||
chain_id TEXT NOT NULL,
|
||||
channel TEXT NOT NULL,
|
||||
asset_type TEXT NOT NULL,
|
||||
coingecko_id TEXT,
|
||||
UNIQUE(chain_id, symbol)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_assets_symbol ON assets(symbol);
|
||||
CREATE INDEX idx_assets_chain_id ON assets(chain_id);
|
||||
CREATE INDEX idx_assets_deleted_at ON assets(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/006_prices_table.down.sql
Normal file
1
internal/migrations/006_prices_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE prices;
|
||||
28
internal/migrations/006_prices_table.up.sql
Normal file
28
internal/migrations/006_prices_table.up.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- Prices entity based on the Alternative.me API for crypto prices
|
||||
CREATE TABLE prices (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
asset_id TEXT NOT NULL,
|
||||
price_usd REAL,
|
||||
price_btc REAL,
|
||||
volume_24h_usd REAL,
|
||||
market_cap_usd REAL,
|
||||
available_supply REAL,
|
||||
total_supply REAL,
|
||||
max_supply REAL,
|
||||
percent_change_1h REAL,
|
||||
percent_change_24h REAL,
|
||||
percent_change_7d REAL,
|
||||
rank INTEGER,
|
||||
last_updated TIMESTAMP NOT NULL,
|
||||
FOREIGN KEY (asset_id) REFERENCES assets(id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_prices_asset_id ON prices(asset_id);
|
||||
CREATE INDEX idx_prices_rank ON prices(rank);
|
||||
CREATE INDEX idx_prices_last_updated ON prices(last_updated);
|
||||
CREATE INDEX idx_prices_deleted_at ON prices(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/007_price_conversions_table.down.sql
Normal file
1
internal/migrations/007_price_conversions_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE price_conversions;
|
||||
21
internal/migrations/007_price_conversions_table.up.sql
Normal file
21
internal/migrations/007_price_conversions_table.up.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- Currency conversion rates for crypto prices
|
||||
CREATE TABLE price_conversions (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
price_id TEXT NOT NULL,
|
||||
currency_code TEXT NOT NULL,
|
||||
price REAL,
|
||||
volume_24h REAL,
|
||||
market_cap REAL,
|
||||
last_updated TIMESTAMP NOT NULL,
|
||||
FOREIGN KEY (price_id) REFERENCES prices(id),
|
||||
UNIQUE(price_id, currency_code)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_price_conversions_price_id ON price_conversions(price_id);
|
||||
CREATE INDEX idx_price_conversions_currency_code ON price_conversions(currency_code);
|
||||
CREATE INDEX idx_price_conversions_deleted_at ON price_conversions(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/008_blockchains_table.down.sql
Normal file
1
internal/migrations/008_blockchains_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE blockchains;
|
||||
71
internal/migrations/008_blockchains_table.up.sql
Normal file
71
internal/migrations/008_blockchains_table.up.sql
Normal file
@@ -0,0 +1,71 @@
|
||||
-- Blockchains table to store chain configuration parameters
|
||||
CREATE TABLE blockchains (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
|
||||
-- Basic chain information
|
||||
chain_name TEXT NOT NULL,
|
||||
chain_id_cosmos TEXT,
|
||||
chain_id_evm TEXT,
|
||||
api_name TEXT,
|
||||
bech_account_prefix TEXT,
|
||||
bech_validator_prefix TEXT,
|
||||
|
||||
-- Chain assets
|
||||
main_asset_symbol TEXT,
|
||||
main_asset_denom TEXT,
|
||||
staking_asset_symbol TEXT,
|
||||
staking_asset_denom TEXT,
|
||||
is_stake_enabled BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_stake_enabled IN (0,1)),
|
||||
|
||||
-- Chain images
|
||||
chain_image TEXT,
|
||||
main_asset_image TEXT,
|
||||
staking_asset_image TEXT,
|
||||
|
||||
-- Chain types and features
|
||||
chain_type TEXT NOT NULL CHECK(json_valid(chain_type)),
|
||||
is_support_mobile_wallet BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_support_mobile_wallet IN (0,1)),
|
||||
is_support_extension_wallet BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_support_extension_wallet IN (0,1)),
|
||||
is_support_erc20 BOOLEAN NOT NULL DEFAULT FALSE CHECK(is_support_erc20 IN (0,1)),
|
||||
|
||||
-- Descriptions in multiple languages
|
||||
description_en TEXT,
|
||||
description_ko TEXT,
|
||||
description_ja TEXT,
|
||||
|
||||
-- Genesis information
|
||||
origin_genesis_time TIMESTAMP,
|
||||
|
||||
-- Account types configuration
|
||||
account_type TEXT NOT NULL CHECK(json_valid(account_type)),
|
||||
|
||||
-- BTC staking specific
|
||||
btc_staking TEXT CHECK(json_valid(btc_staking)),
|
||||
|
||||
-- Cosmos fee information
|
||||
cosmos_fee_info TEXT CHECK(json_valid(cosmos_fee_info)),
|
||||
|
||||
-- EVM fee information
|
||||
evm_fee_info TEXT CHECK(json_valid(evm_fee_info)),
|
||||
|
||||
-- Endpoints
|
||||
lcd_endpoint TEXT CHECK(json_valid(lcd_endpoint)),
|
||||
grpc_endpoint TEXT CHECK(json_valid(grpc_endpoint)),
|
||||
evm_rpc_endpoint TEXT CHECK(json_valid(evm_rpc_endpoint)),
|
||||
|
||||
-- Explorer information
|
||||
explorer TEXT CHECK(json_valid(explorer)),
|
||||
|
||||
-- Social and documentation links
|
||||
about TEXT CHECK(json_valid(about)),
|
||||
forum TEXT CHECK(json_valid(forum))
|
||||
);
|
||||
|
||||
CREATE INDEX idx_blockchains_chain_name ON blockchains(chain_name);
|
||||
CREATE INDEX idx_blockchains_chain_id_cosmos ON blockchains(chain_id_cosmos);
|
||||
CREATE INDEX idx_blockchains_chain_id_evm ON blockchains(chain_id_evm);
|
||||
CREATE INDEX idx_blockchains_main_asset_symbol ON blockchains(main_asset_symbol);
|
||||
CREATE INDEX idx_blockchains_deleted_at ON blockchains(deleted_at);
|
||||
1
internal/migrations/009_services_table.down.sql
Normal file
1
internal/migrations/009_services_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE services;
|
||||
24
internal/migrations/009_services_table.up.sql
Normal file
24
internal/migrations/009_services_table.up.sql
Normal file
@@ -0,0 +1,24 @@
|
||||
-- Service for Service Records sourced on chain
|
||||
CREATE TABLE services (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
name TEXT NOT NULL,
|
||||
description TEXT,
|
||||
chain_id TEXT NOT NULL,
|
||||
address TEXT NOT NULL,
|
||||
owner_address TEXT NOT NULL,
|
||||
metadata TEXT CHECK(json_valid(metadata)),
|
||||
status TEXT NOT NULL,
|
||||
block_height INTEGER NOT NULL,
|
||||
FOREIGN KEY (chain_id) REFERENCES assets(chain_id),
|
||||
UNIQUE(chain_id, address)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_services_name ON services(name);
|
||||
CREATE INDEX idx_services_chain_id ON services(chain_id);
|
||||
CREATE INDEX idx_services_address ON services(address);
|
||||
CREATE INDEX idx_services_owner_address ON services(owner_address);
|
||||
CREATE INDEX idx_services_status ON services(status);
|
||||
CREATE INDEX idx_services_deleted_at ON services(deleted_at);
|
||||
1
internal/migrations/010_activities_table.down.sql
Normal file
1
internal/migrations/010_activities_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE activities;
|
||||
32
internal/migrations/010_activities_table.up.sql
Normal file
32
internal/migrations/010_activities_table.up.sql
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
-- Activity table for basic transaction broadcast activity
|
||||
CREATE TABLE activities (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
account_id TEXT NOT NULL,
|
||||
tx_hash TEXT,
|
||||
tx_type TEXT NOT NULL,
|
||||
status TEXT NOT NULL,
|
||||
amount TEXT,
|
||||
fee TEXT,
|
||||
gas_used INTEGER,
|
||||
gas_wanted INTEGER,
|
||||
memo TEXT,
|
||||
block_height INTEGER,
|
||||
timestamp TIMESTAMP NOT NULL,
|
||||
raw_log TEXT,
|
||||
error TEXT,
|
||||
FOREIGN KEY (account_id) REFERENCES accounts(id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_activities_account_id ON activities(account_id);
|
||||
CREATE INDEX idx_activities_tx_hash ON activities(tx_hash);
|
||||
CREATE INDEX idx_activities_tx_type ON activities(tx_type);
|
||||
CREATE INDEX idx_activities_status ON activities(status);
|
||||
CREATE INDEX idx_activities_timestamp ON activities(timestamp);
|
||||
CREATE INDEX idx_activities_block_height ON activities(block_height);
|
||||
CREATE INDEX idx_activities_deleted_at ON activities(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/011_health_table.down.sql
Normal file
1
internal/migrations/011_health_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE health;
|
||||
28
internal/migrations/011_health_table.up.sql
Normal file
28
internal/migrations/011_health_table.up.sql
Normal file
@@ -0,0 +1,28 @@
|
||||
-- Health table for scheduled checks for API endpoints
|
||||
CREATE TABLE health (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
endpoint_url TEXT NOT NULL,
|
||||
endpoint_type TEXT NOT NULL,
|
||||
chain_id TEXT,
|
||||
status TEXT NOT NULL,
|
||||
response_time_ms INTEGER,
|
||||
last_checked TIMESTAMP NOT NULL,
|
||||
next_check TIMESTAMP,
|
||||
failure_count INTEGER NOT NULL DEFAULT 0,
|
||||
success_count INTEGER NOT NULL DEFAULT 0,
|
||||
response_data TEXT,
|
||||
error_message TEXT,
|
||||
FOREIGN KEY (chain_id) REFERENCES assets(chain_id)
|
||||
);
|
||||
|
||||
CREATE INDEX idx_health_endpoint_url ON health(endpoint_url);
|
||||
CREATE INDEX idx_health_endpoint_type ON health(endpoint_type);
|
||||
CREATE INDEX idx_health_chain_id ON health(chain_id);
|
||||
CREATE INDEX idx_health_status ON health(status);
|
||||
CREATE INDEX idx_health_last_checked ON health(last_checked);
|
||||
CREATE INDEX idx_health_next_check ON health(next_check);
|
||||
CREATE INDEX idx_health_deleted_at ON health(deleted_at);
|
||||
|
||||
1
internal/migrations/012_global_market_table.down.sql
Normal file
1
internal/migrations/012_global_market_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE global_market;
|
||||
19
internal/migrations/012_global_market_table.up.sql
Normal file
19
internal/migrations/012_global_market_table.up.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Global market data from Alternative.me API
|
||||
CREATE TABLE global_market (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
total_market_cap_usd REAL,
|
||||
total_24h_volume_usd REAL,
|
||||
bitcoin_percentage_of_market_cap REAL,
|
||||
active_currencies INTEGER,
|
||||
active_assets INTEGER,
|
||||
active_markets INTEGER,
|
||||
last_updated TIMESTAMP NOT NULL
|
||||
);
|
||||
|
||||
CREATE INDEX idx_global_market_last_updated ON global_market(last_updated);
|
||||
CREATE INDEX idx_global_market_deleted_at ON global_market(deleted_at);
|
||||
|
||||
|
||||
1
internal/migrations/013_fear_greed_index_table.down.sql
Normal file
1
internal/migrations/013_fear_greed_index_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE fear_greed_index;
|
||||
15
internal/migrations/013_fear_greed_index_table.up.sql
Normal file
15
internal/migrations/013_fear_greed_index_table.up.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- Fear and Greed Index data from Alternative.me
|
||||
CREATE TABLE fear_greed_index (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
value INTEGER NOT NULL,
|
||||
value_classification TEXT NOT NULL,
|
||||
timestamp TIMESTAMP NOT NULL,
|
||||
time_until_update TEXT
|
||||
);
|
||||
|
||||
CREATE INDEX idx_fear_greed_index_timestamp ON fear_greed_index(timestamp);
|
||||
CREATE INDEX idx_fear_greed_index_value ON fear_greed_index(value);
|
||||
CREATE INDEX idx_fear_greed_index_deleted_at ON fear_greed_index(deleted_at);
|
||||
1
internal/migrations/014_crypto_listings_table.down.sql
Normal file
1
internal/migrations/014_crypto_listings_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE crypto_listings;
|
||||
18
internal/migrations/014_crypto_listings_table.up.sql
Normal file
18
internal/migrations/014_crypto_listings_table.up.sql
Normal file
@@ -0,0 +1,18 @@
|
||||
-- Listings data from Alternative.me API
|
||||
CREATE TABLE crypto_listings (
|
||||
id TEXT PRIMARY KEY,
|
||||
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deleted_at TIMESTAMP,
|
||||
api_id TEXT NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
symbol TEXT NOT NULL,
|
||||
website_slug TEXT NOT NULL,
|
||||
UNIQUE(api_id)
|
||||
);
|
||||
|
||||
|
||||
CREATE INDEX idx_crypto_listings_api_id ON crypto_listings(api_id);
|
||||
CREATE INDEX idx_crypto_listings_symbol ON crypto_listings(symbol);
|
||||
CREATE INDEX idx_crypto_listings_website_slug ON crypto_listings(website_slug);
|
||||
CREATE INDEX idx_crypto_listings_deleted_at ON crypto_listings(deleted_at);
|
||||
200
internal/migrations/Taskfile.yml
Normal file
200
internal/migrations/Taskfile.yml
Normal file
@@ -0,0 +1,200 @@
|
||||
# yaml-language-server: $schema=https://taskfile.dev/schema.json
|
||||
version: "3"
|
||||
silent: true
|
||||
|
||||
tasks:
|
||||
default:
|
||||
cmds:
|
||||
- task: migrate
|
||||
|
||||
initialize:
|
||||
cmds:
|
||||
- task: migrate:accounts:up
|
||||
- task: migrate:credentials:up
|
||||
- task: migrate:profiles:up
|
||||
- task: migrate:vaults:up
|
||||
- task: migrate:assets:up
|
||||
- task: migrate:prices:up
|
||||
- task: migrate:price_conversions:up
|
||||
- task: migrate:blockchains:up
|
||||
- task: migrate:services:up
|
||||
- task: migrate:activities:up
|
||||
- task: migrate:health:up
|
||||
- task: migrate:global_market:up
|
||||
- task: migrate:fear_greed_index:up
|
||||
- task: migrate:crypto_listings:up
|
||||
|
||||
migrate:
|
||||
cmds:
|
||||
- task: migrate:accounts
|
||||
- task: migrate:credentials
|
||||
- task: migrate:profiles
|
||||
- task: migrate:vaults
|
||||
- task: migrate:assets
|
||||
- task: migrate:prices
|
||||
- task: migrate:price_conversions
|
||||
- task: migrate:blockchains
|
||||
- task: migrate:services
|
||||
- task: migrate:activities
|
||||
- task: migrate:health
|
||||
- task: migrate:global_market
|
||||
- task: migrate:fear_greed_index
|
||||
- task: migrate:crypto_listings
|
||||
|
||||
# ---------------
|
||||
# Main Tasks
|
||||
# ---------------
|
||||
migrate:accounts:
|
||||
cmds:
|
||||
- task: migrate:accounts:down
|
||||
- task: migrate:accounts:up
|
||||
|
||||
migrate:accounts:up:
|
||||
cmd: wrangler d1 execute USERS_DB --file 001_accounts_table.up.sql --remote -y
|
||||
|
||||
migrate:accounts:down:
|
||||
cmd: wrangler d1 execute USERS_DB --file 001_accounts_table.down.sql --remote -y
|
||||
|
||||
migrate:credentials:
|
||||
cmds:
|
||||
- task: migrate:credentials:down
|
||||
- task: migrate:credentials:up
|
||||
|
||||
migrate:credentials:up:
|
||||
cmd: wrangler d1 execute USERS_DB --file 002_credentials_table.up.sql --remote -y
|
||||
|
||||
migrate:credentials:down:
|
||||
cmd: wrangler d1 execute USERS_DB --file 002_credentials_table.down.sql --remote -y
|
||||
|
||||
migrate:profiles:
|
||||
cmds:
|
||||
- task: migrate:profiles:down
|
||||
- task: migrate:profiles:up
|
||||
|
||||
migrate:profiles:up:
|
||||
cmd: wrangler d1 execute USERS_DB --file 003_profiles_table.up.sql --remote -y
|
||||
|
||||
migrate:profiles:down:
|
||||
cmd: wrangler d1 execute USERS_DB --file 003_profiles_table.down.sql --remote -y
|
||||
|
||||
migrate:vaults:
|
||||
cmds:
|
||||
- task: migrate:vaults:down
|
||||
- task: migrate:vaults:up
|
||||
|
||||
migrate:vaults:down:
|
||||
cmd: wrangler d1 execute USERS_DB --file 004_vaults_table.down.sql --remote -y
|
||||
|
||||
migrate:vaults:up:
|
||||
cmd: wrangler d1 execute USERS_DB --file 004_vaults_table.up.sql --remote -y
|
||||
|
||||
migrate:assets:
|
||||
cmds:
|
||||
- task: migrate:assets:down
|
||||
- task: migrate:assets:up
|
||||
|
||||
migrate:assets:up:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 005_assets_table.up.sql --remote -y
|
||||
|
||||
migrate:assets:down:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 005_assets_table.down.sql --remote -y
|
||||
|
||||
migrate:prices:
|
||||
cmds:
|
||||
- task: migrate:prices:down
|
||||
- task: migrate:prices:up
|
||||
|
||||
migrate:prices:up:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 006_prices_table.up.sql --remote -y
|
||||
|
||||
migrate:prices:down:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 006_prices_table.down.sql --remote -y
|
||||
|
||||
migrate:price_conversions:
|
||||
cmds:
|
||||
- task: migrate:price_conversions:down
|
||||
- task: migrate:price_conversions:up
|
||||
|
||||
migrate:price_conversions:up:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 007_price_conversions_table.up.sql --remote -y
|
||||
|
||||
migrate:price_conversions:down:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 007_price_conversions_table.down.sql --remote -y
|
||||
|
||||
migrate:blockchains:
|
||||
cmds:
|
||||
- task: migrate:blockchains:down
|
||||
- task: migrate:blockchains:up
|
||||
|
||||
migrate:blockchains:up:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 008_blockchains_table.up.sql --remote -y
|
||||
|
||||
migrate:blockchains:down:
|
||||
cmd: wrangler d1 execute NETWORK_DB --file 008_blockchains_table.down.sql --remote -y
|
||||
|
||||
migrate:services:
|
||||
cmds:
|
||||
- task: migrate:services:down
|
||||
- task: migrate:services:up
|
||||
|
||||
migrate:services:up:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 009_services_table.up.sql --remote -y
|
||||
|
||||
migrate:services:down:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 009_services_table.down.sql --remote -y
|
||||
|
||||
migrate:activities:
|
||||
cmds:
|
||||
- task: migrate:activities:down
|
||||
- task: migrate:activities:up
|
||||
|
||||
migrate:activities:up:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 010_activities_table.up.sql --remote -y
|
||||
|
||||
migrate:activities:down:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 010_activities_table.down.sql --remote -y
|
||||
|
||||
migrate:health:
|
||||
cmds:
|
||||
- task: migrate:health:down
|
||||
- task: migrate:health:up
|
||||
|
||||
migrate:health:up:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 011_health_table.up.sql --remote -y
|
||||
|
||||
migrate:health:down:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 011_health_table.down.sql --remote -y
|
||||
|
||||
migrate:global_market:
|
||||
cmds:
|
||||
- task: global_market:down
|
||||
- task: global_market:up
|
||||
|
||||
migrate:global_market:up:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 012_global_market_table.up.sql --remote -y
|
||||
|
||||
migrate:global_market:down:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 012_global_market_table.down.sql --remote -y
|
||||
|
||||
migrate:fear_greed_index:
|
||||
cmds:
|
||||
- task: migrate:fear_greed_index:down
|
||||
- task: migrate:fear_greed_index:up
|
||||
|
||||
migrate:fear_greed_index:up:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 013_fear_greed_index_table.up.sql --remote -y
|
||||
|
||||
migrate:fear_greed_index:down:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 013_fear_greed_index_table.down.sql --remote -y
|
||||
|
||||
migrate:crypto_listings:
|
||||
cmds:
|
||||
- task: migrate:crypto_listings:down
|
||||
- task: migrate:crypto_listings:up
|
||||
|
||||
migrate:crypto_listings:up:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 014_crypto_listings_table.up.sql --remote -y
|
||||
|
||||
migrate:crypto_listings:down:
|
||||
cmd: wrangler d1 execute ACTIVITY_DB --file 014_crypto_listings_table.down.sql --remote -y
|
||||
|
||||
6
internal/migrations/node_modules/.cache/wrangler/wrangler-account.json
generated
vendored
Normal file
6
internal/migrations/node_modules/.cache/wrangler/wrangler-account.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"account": {
|
||||
"id": "eb37925850388bca807b7fab964c12bb",
|
||||
"name": "Sonr"
|
||||
}
|
||||
}
|
||||
1
internal/migrations/node_modules/.mf/cf.json
generated
vendored
Normal file
1
internal/migrations/node_modules/.mf/cf.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"clientTcpRtt":8,"requestHeaderNames":{},"httpProtocol":"HTTP/1.1","tlsCipher":"AEAD-AES256-GCM-SHA384","continent":"NA","asn":701,"clientAcceptEncoding":"br, gzip, deflate","verifiedBotCategory":"","country":"US","region":"Virginia","tlsClientCiphersSha1":"kXrN3VEKDdzz2cPKTQaKzpxVTxQ=","tlsClientAuth":{"certIssuerDNLegacy":"","certIssuerSKI":"","certSubjectDNRFC2253":"","certSubjectDNLegacy":"","certFingerprintSHA256":"","certNotBefore":"","certSKI":"","certSerial":"","certIssuerDN":"","certVerified":"NONE","certNotAfter":"","certSubjectDN":"","certPresented":"0","certRevoked":"0","certIssuerSerial":"","certIssuerDNRFC2253":"","certFingerprintSHA1":""},"tlsClientRandom":"KHkBe8nH4XNP9wnNS5nCDWBpe+Ha+8+BUuP0iev0P7Q=","tlsExportedAuthenticator":{"clientFinished":"c71857a631b6612f8bdfda376b597ddb0ccf62688fc7f50086006daba82f54c412501557ccfce73754bc550a1e09a6b9","clientHandshake":"8d0a2b64f7b6d0d1c2a77d7535feca90c9703a46c457b4951670146a8b5e2fe89357c6d8666c4e7f864e6814e7bb1d0f","serverHandshake":"429ef59250f50d719b076c2efdf97ecd5d1a50c15fdf979df5894d078793865ff44c7680213365147c44daedbc92bec6","serverFinished":"6e46d6694b01edbbc7d5daa9316565f17fb3a626713c96286d07487a7ddb7482aea03a84971fc74231d848d2f037af41"},"tlsClientHelloLength":"383","colo":"IAD","timezone":"America/New_York","longitude":"-77.53900","latitude":"39.01800","edgeRequestKeepAliveStatus":1,"requestPriority":"","postalCode":"20147","city":"Ashburn","tlsVersion":"TLSv1.3","regionCode":"VA","asOrganization":"Verizon Fios","metroCode":"511","tlsClientExtensionsSha1Le":"u4wtEMFQBY18l3BzHAvORm+KGRw=","tlsClientExtensionsSha1":"1eY97BUYYO8vDaTfHQywB1pcNdM=","botManagement":{"corporateProxy":false,"verifiedBot":false,"jsDetection":{"passed":false},"staticResource":false,"detectionIds":{},"score":99}}
|
||||
64
internal/migrations/wrangler.toml
Normal file
64
internal/migrations/wrangler.toml
Normal file
@@ -0,0 +1,64 @@
|
||||
# Top-level configuration
|
||||
name = "motr-worker"
|
||||
main = "worker.mjs"
|
||||
compatibility_date = "2025-04-14"
|
||||
|
||||
routes = [
|
||||
{ pattern = "sonr.id", custom_domain = true },
|
||||
]
|
||||
|
||||
[build]
|
||||
command = "devbox run build:worker"
|
||||
|
||||
[dev]
|
||||
port = 6969
|
||||
|
||||
[observability]
|
||||
enabled = true
|
||||
|
||||
[triggers]
|
||||
crons = ["0 */1 * * *"]
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "ACTIVITY_DB"
|
||||
database_name = "motr-activity"
|
||||
database_id = "a7ccb4bb-c529-4f42-8029-92564a3aecb8"
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "NETWORK_DB"
|
||||
database_name = "motr-network"
|
||||
database_id = "acb75499-3502-4052-9604-263a913e077a"
|
||||
|
||||
[[d1_databases]]
|
||||
binding = "USERS_DB"
|
||||
database_name = "motr-users"
|
||||
database_id = "8ed4d399-5932-419c-b92f-9c20d7a36ad2"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "SESSIONS_KV"
|
||||
id = "ea5de66fcfc14b5eba170395e29432ee"
|
||||
|
||||
[[kv_namespaces]]
|
||||
binding = "HANDLES_KV"
|
||||
id = "271d47087a8842b2aac5ee79cf7bb203"
|
||||
|
||||
[[r2_buckets]]
|
||||
binding = 'PROFILES'
|
||||
bucket_name = 'profiles'
|
||||
|
||||
[vars]
|
||||
SONR_CHAIN_ID = 'sonr-testnet-1'
|
||||
IPFS_GATEWAY = 'https://ipfs.sonr.land'
|
||||
SONR_API_URL = 'https://api.sonr.land'
|
||||
SONR_RPC_URL = 'https://rpc.sonr.land'
|
||||
SONR_GRPC_URL = 'https://grpc.sonr.land'
|
||||
MATRIX_SERVER = 'https://bm.chat'
|
||||
MOTR_GATEWAY = 'https://sonr.id'
|
||||
MOTR_VAULT = 'https://did.run'
|
||||
|
||||
[durable_objects]
|
||||
bindings = [{name = "VAULT", class_name = "Vault"}]
|
||||
|
||||
[[migrations]]
|
||||
tag = "v1" # Should be unique for each entry
|
||||
new_classes = ["Vault"] # List the classes that should be created
|
||||
Reference in New Issue
Block a user