0.7.14
This commit is contained in:
@@ -254,6 +254,26 @@ pub(crate) async fn ensure_schema(database: &crate::KbDatabase) -> Result<(), cr
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_pool_origins_table(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_pool_origins_dex_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_pool_origins_pair_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_pool_origins_listing_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_pool_origins_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1392,3 +1412,89 @@ ON kb_launch_attributions(pool_id)
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create_kb_pool_origins_table(pool: &sqlx::SqlitePool) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_pool_origins_table",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS kb_pool_origins (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
dex_id INTEGER NOT NULL,
|
||||
pool_id INTEGER NOT NULL UNIQUE,
|
||||
pair_id INTEGER NULL,
|
||||
pool_listing_id INTEGER NULL,
|
||||
founding_transaction_id INTEGER NOT NULL,
|
||||
founding_decoded_event_id INTEGER NOT NULL UNIQUE,
|
||||
founding_signature TEXT NOT NULL,
|
||||
founding_protocol_name TEXT NOT NULL,
|
||||
founding_event_kind TEXT NOT NULL,
|
||||
source_kind INTEGER NOT NULL,
|
||||
source_endpoint_name TEXT NULL,
|
||||
launch_attribution_id INTEGER NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
FOREIGN KEY(dex_id) REFERENCES kb_dexes(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(pool_id) REFERENCES kb_pools(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(pair_id) REFERENCES kb_pairs(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY(pool_listing_id) REFERENCES kb_pool_listings(id) ON DELETE SET NULL,
|
||||
FOREIGN KEY(founding_transaction_id) REFERENCES kb_chain_transactions(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(founding_decoded_event_id) REFERENCES kb_dex_decoded_events(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY(launch_attribution_id) REFERENCES kb_launch_attributions(id) ON DELETE SET NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create_kb_idx_pool_origins_dex_id(pool: &sqlx::SqlitePool) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_pool_origins_dex_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_pool_origins_dex_id
|
||||
ON kb_pool_origins(dex_id)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create_kb_idx_pool_origins_pair_id(pool: &sqlx::SqlitePool) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_pool_origins_pair_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_pool_origins_pair_id
|
||||
ON kb_pool_origins(pair_id)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create_kb_idx_pool_origins_listing_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_pool_origins_listing_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_pool_origins_listing_id
|
||||
ON kb_pool_origins(pool_listing_id)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn create_kb_idx_pool_origins_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_pool_origins_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_pool_origins_transaction_id
|
||||
ON kb_pool_origins(founding_transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user