0.7.28
This commit is contained in:
@@ -230,6 +230,94 @@ pub(crate) async fn ensure_schema(database: &crate::Database) -> Result<(), crat
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_transaction_classifications(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_uix_transaction_classifications_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_transaction_classifications_kind(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_protocol_candidates(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_protocol_candidates_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_protocol_candidates_program_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_pool_lifecycle_events(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_pool_lifecycle_events_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_pool_lifecycle_events_pool_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_uix_pool_lifecycle_events_decoded_event_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_fee_events(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_fee_events_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_fee_events_pool_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_uix_fee_events_decoded_event_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_reward_events(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_reward_events_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_reward_events_pool_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_uix_reward_events_decoded_event_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_pool_admin_events(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_pool_admin_events_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_idx_pool_admin_events_pool_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_uix_pool_admin_events_decoded_event_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_tbl_launch_surfaces(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
@@ -1878,3 +1966,413 @@ ON k_sol_pair_analytic_signals(pair_id)
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates `k_sol_transaction_classifications`.
|
||||
async fn create_tbl_transaction_classifications(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_tbl_transaction_classifications",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS k_sol_transaction_classifications (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
signature TEXT NOT NULL,
|
||||
slot INTEGER NULL,
|
||||
classification_kind TEXT NOT NULL,
|
||||
primary_protocol TEXT NULL,
|
||||
primary_program_id TEXT NULL,
|
||||
confidence_level INTEGER NOT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
evidence_json TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates unique index on `k_sol_transaction_classifications(transaction_id)`.
|
||||
async fn create_uix_transaction_classifications_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_uix_transaction_classifications_transaction_id",
|
||||
r#"
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uix_transaction_classifications_transaction_id
|
||||
ON k_sol_transaction_classifications (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_transaction_classifications(classification_kind)`.
|
||||
async fn create_idx_transaction_classifications_kind(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_transaction_classifications_kind",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_transaction_classifications_kind
|
||||
ON k_sol_transaction_classifications (classification_kind)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates `k_sol_protocol_candidates`.
|
||||
async fn create_tbl_protocol_candidates(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_tbl_protocol_candidates",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS k_sol_protocol_candidates (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
instruction_id INTEGER NULL,
|
||||
signature TEXT NOT NULL,
|
||||
slot INTEGER NULL,
|
||||
program_id TEXT NOT NULL,
|
||||
program_name_hint TEXT NULL,
|
||||
candidate_protocol TEXT NULL,
|
||||
candidate_surface TEXT NULL,
|
||||
reason TEXT NOT NULL,
|
||||
evidence_json TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_protocol_candidates(transaction_id)`.
|
||||
async fn create_idx_protocol_candidates_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_protocol_candidates_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_protocol_candidates_transaction_id
|
||||
ON k_sol_protocol_candidates (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_protocol_candidates(program_id)`.
|
||||
async fn create_idx_protocol_candidates_program_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_protocol_candidates_program_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_protocol_candidates_program_id
|
||||
ON k_sol_protocol_candidates (program_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates `k_sol_pool_lifecycle_events`.
|
||||
async fn create_tbl_pool_lifecycle_events(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_tbl_pool_lifecycle_events",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS k_sol_pool_lifecycle_events (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
decoded_event_id INTEGER NULL,
|
||||
dex_id INTEGER NULL,
|
||||
pool_id INTEGER NULL,
|
||||
pair_id INTEGER NULL,
|
||||
signature TEXT NOT NULL,
|
||||
slot INTEGER NULL,
|
||||
protocol_name TEXT NOT NULL,
|
||||
program_id TEXT NOT NULL,
|
||||
event_kind TEXT NOT NULL,
|
||||
pool_account TEXT NULL,
|
||||
token_a_mint TEXT NULL,
|
||||
token_b_mint TEXT NULL,
|
||||
payload_json TEXT NOT NULL,
|
||||
executed_at TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_pool_lifecycle_events(transaction_id)`.
|
||||
async fn create_idx_pool_lifecycle_events_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_pool_lifecycle_events_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_pool_lifecycle_events_transaction_id
|
||||
ON k_sol_pool_lifecycle_events (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_pool_lifecycle_events(pool_id)`.
|
||||
async fn create_idx_pool_lifecycle_events_pool_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_pool_lifecycle_events_pool_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_pool_lifecycle_events_pool_id
|
||||
ON k_sol_pool_lifecycle_events (pool_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates partial unique index on `k_sol_pool_lifecycle_events(decoded_event_id)`.
|
||||
async fn create_uix_pool_lifecycle_events_decoded_event_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_uix_pool_lifecycle_events_decoded_event_id",
|
||||
r#"
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uix_pool_lifecycle_events_decoded_event_id
|
||||
ON k_sol_pool_lifecycle_events (decoded_event_id)
|
||||
WHERE decoded_event_id IS NOT NULL
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates `k_sol_fee_events`.
|
||||
async fn create_tbl_fee_events(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_tbl_fee_events",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS k_sol_fee_events (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
decoded_event_id INTEGER NULL,
|
||||
dex_id INTEGER NULL,
|
||||
pool_id INTEGER NULL,
|
||||
pair_id INTEGER NULL,
|
||||
signature TEXT NOT NULL,
|
||||
slot INTEGER NULL,
|
||||
protocol_name TEXT NOT NULL,
|
||||
program_id TEXT NOT NULL,
|
||||
event_kind TEXT NOT NULL,
|
||||
pool_account TEXT NULL,
|
||||
actor_wallet TEXT NULL,
|
||||
fee_token_mint TEXT NULL,
|
||||
fee_amount_raw TEXT NULL,
|
||||
payload_json TEXT NOT NULL,
|
||||
executed_at TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_fee_events(transaction_id)`.
|
||||
async fn create_idx_fee_events_transaction_id(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_fee_events_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_fee_events_transaction_id
|
||||
ON k_sol_fee_events (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_fee_events(pool_id)`.
|
||||
async fn create_idx_fee_events_pool_id(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_fee_events_pool_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_fee_events_pool_id
|
||||
ON k_sol_fee_events (pool_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates partial unique index on `k_sol_fee_events(decoded_event_id)`.
|
||||
async fn create_uix_fee_events_decoded_event_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_uix_fee_events_decoded_event_id",
|
||||
r#"
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uix_fee_events_decoded_event_id
|
||||
ON k_sol_fee_events (decoded_event_id)
|
||||
WHERE decoded_event_id IS NOT NULL
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates `k_sol_reward_events`.
|
||||
async fn create_tbl_reward_events(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_tbl_reward_events",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS k_sol_reward_events (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
decoded_event_id INTEGER NULL,
|
||||
dex_id INTEGER NULL,
|
||||
pool_id INTEGER NULL,
|
||||
pair_id INTEGER NULL,
|
||||
signature TEXT NOT NULL,
|
||||
slot INTEGER NULL,
|
||||
protocol_name TEXT NOT NULL,
|
||||
program_id TEXT NOT NULL,
|
||||
event_kind TEXT NOT NULL,
|
||||
pool_account TEXT NULL,
|
||||
actor_wallet TEXT NULL,
|
||||
reward_token_mint TEXT NULL,
|
||||
reward_amount_raw TEXT NULL,
|
||||
payload_json TEXT NOT NULL,
|
||||
executed_at TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_reward_events(transaction_id)`.
|
||||
async fn create_idx_reward_events_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_reward_events_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_reward_events_transaction_id
|
||||
ON k_sol_reward_events (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_reward_events(pool_id)`.
|
||||
async fn create_idx_reward_events_pool_id(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_reward_events_pool_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_reward_events_pool_id
|
||||
ON k_sol_reward_events (pool_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates partial unique index on `k_sol_reward_events(decoded_event_id)`.
|
||||
async fn create_uix_reward_events_decoded_event_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_uix_reward_events_decoded_event_id",
|
||||
r#"
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uix_reward_events_decoded_event_id
|
||||
ON k_sol_reward_events (decoded_event_id)
|
||||
WHERE decoded_event_id IS NOT NULL
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates `k_sol_pool_admin_events`.
|
||||
async fn create_tbl_pool_admin_events(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_tbl_pool_admin_events",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS k_sol_pool_admin_events (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
decoded_event_id INTEGER NULL,
|
||||
dex_id INTEGER NULL,
|
||||
pool_id INTEGER NULL,
|
||||
pair_id INTEGER NULL,
|
||||
signature TEXT NOT NULL,
|
||||
slot INTEGER NULL,
|
||||
protocol_name TEXT NOT NULL,
|
||||
program_id TEXT NOT NULL,
|
||||
event_kind TEXT NOT NULL,
|
||||
pool_account TEXT NULL,
|
||||
actor_wallet TEXT NULL,
|
||||
admin_action TEXT NULL,
|
||||
payload_json TEXT NOT NULL,
|
||||
executed_at TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_pool_admin_events(transaction_id)`.
|
||||
async fn create_idx_pool_admin_events_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_pool_admin_events_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_pool_admin_events_transaction_id
|
||||
ON k_sol_pool_admin_events (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates index on `k_sol_pool_admin_events(pool_id)`.
|
||||
async fn create_idx_pool_admin_events_pool_id(pool: &sqlx::SqlitePool) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_idx_pool_admin_events_pool_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS idx_pool_admin_events_pool_id
|
||||
ON k_sol_pool_admin_events (pool_id)
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
/// Creates partial unique index on `k_sol_pool_admin_events(decoded_event_id)`.
|
||||
async fn create_uix_pool_admin_events_decoded_event_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::Error> {
|
||||
return execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_uix_pool_admin_events_decoded_event_id",
|
||||
r#"
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uix_pool_admin_events_decoded_event_id
|
||||
ON k_sol_pool_admin_events (decoded_event_id)
|
||||
WHERE decoded_event_id IS NOT NULL
|
||||
"#,
|
||||
)
|
||||
.await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user