0.7.1 for Real ! - it was 0.7.0 before, not 0.7.1 !!
This commit is contained in:
@@ -190,10 +190,35 @@ pub(crate) async fn ensure_schema(database: &crate::KbDatabase) -> Result<(), cr
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_chain_slots_table(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_chain_transactions_table(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_chain_transactions_slot(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_chain_instructions_table(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_chain_instructions_transaction_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = create_kb_idx_chain_instructions_program_id(pool).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
let result = update_schema_version_metadata(database).await;
|
||||
if let Err(error) = result {
|
||||
return Err(error);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1029,6 +1054,126 @@ ON kb_token_burn_events (executed_at)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates `kb_chain_slots`.
|
||||
async fn create_kb_chain_slots_table(pool: &sqlx::SqlitePool) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_chain_slots_table",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS kb_chain_slots (
|
||||
slot INTEGER NOT NULL PRIMARY KEY,
|
||||
parent_slot INTEGER NULL,
|
||||
block_time_unix INTEGER NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates `kb_chain_transactions`.
|
||||
async fn create_kb_chain_transactions_table(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_chain_transactions_table",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS kb_chain_transactions (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
signature TEXT NOT NULL UNIQUE,
|
||||
slot INTEGER NULL,
|
||||
block_time_unix INTEGER NULL,
|
||||
source_endpoint_name TEXT NULL,
|
||||
version_text TEXT NULL,
|
||||
err_json TEXT NULL,
|
||||
meta_json TEXT NULL,
|
||||
transaction_json TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
updated_at TEXT NOT NULL,
|
||||
FOREIGN KEY(slot) REFERENCES kb_chain_slots(slot)
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates index on `kb_chain_transactions(slot)`.
|
||||
async fn create_kb_idx_chain_transactions_slot(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_chain_transactions_slot",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_chain_transactions_slot
|
||||
ON kb_chain_transactions (slot)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates `kb_chain_instructions`.
|
||||
async fn create_kb_chain_instructions_table(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_chain_instructions_table",
|
||||
r#"
|
||||
CREATE TABLE IF NOT EXISTS kb_chain_instructions (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
transaction_id INTEGER NOT NULL,
|
||||
parent_instruction_id INTEGER NULL,
|
||||
instruction_index INTEGER NOT NULL,
|
||||
inner_instruction_index INTEGER NULL,
|
||||
program_id TEXT NULL,
|
||||
program_name TEXT NULL,
|
||||
stack_height INTEGER NULL,
|
||||
accounts_json TEXT NOT NULL,
|
||||
data_json TEXT NULL,
|
||||
parsed_type TEXT NULL,
|
||||
parsed_json TEXT NULL,
|
||||
created_at TEXT NOT NULL,
|
||||
FOREIGN KEY(transaction_id) REFERENCES kb_chain_transactions(id),
|
||||
FOREIGN KEY(parent_instruction_id) REFERENCES kb_chain_instructions(id)
|
||||
)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates index on `kb_chain_instructions(transaction_id)`.
|
||||
async fn create_kb_idx_chain_instructions_transaction_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_chain_instructions_transaction_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_chain_instructions_transaction_id
|
||||
ON kb_chain_instructions (transaction_id)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Creates index on `kb_chain_instructions(program_id)`.
|
||||
async fn create_kb_idx_chain_instructions_program_id(
|
||||
pool: &sqlx::SqlitePool,
|
||||
) -> Result<(), crate::KbError> {
|
||||
execute_sqlite_schema_statement(
|
||||
pool,
|
||||
"create_kb_idx_chain_instructions_program_id",
|
||||
r#"
|
||||
CREATE INDEX IF NOT EXISTS kb_idx_chain_instructions_program_id
|
||||
ON kb_chain_instructions (program_id)
|
||||
"#,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Updates the persisted schema version metadata entry.
|
||||
async fn update_schema_version_metadata(
|
||||
database: &crate::KbDatabase,
|
||||
|
||||
Reference in New Issue
Block a user