0.5.1-pre.002
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: kb-app-demo-desktop/src/demo_sql_common.rs
|
||||
// version: 12
|
||||
// version: 13
|
||||
|
||||
//! Shared SQL demo helpers and serializable payloads.
|
||||
|
||||
@@ -34,12 +34,12 @@ pub(crate) struct DemoSqlTableSnapshot {
|
||||
pub(crate) latest_created_at: std::option::Option<std::string::String>,
|
||||
}
|
||||
|
||||
/// Builds PostgreSQL options from the active profile without coupling kb-store to kb-config.
|
||||
/// Builds PostgreSQL options from the active profile without coupling ks-store to ks-config.
|
||||
pub(crate) fn postgres_store_options_from_profile(
|
||||
profile: &kb_config::ProfileConfig,
|
||||
profile: &ks_config::ProfileConfig,
|
||||
auto_initialize_schema: bool,
|
||||
) -> kb_core::Result<kb_store::PostgresStoreOptions> {
|
||||
return kb_store::PostgresStoreOptions::new(
|
||||
) -> ks_core::Result<ks_store::PostgresStoreOptions> {
|
||||
return ks_store::PostgresStoreOptions::new(
|
||||
profile.database.postgres.url.clone(),
|
||||
profile.database.postgres.max_connections,
|
||||
profile.database.postgres.connect_timeout_ms,
|
||||
@@ -49,8 +49,8 @@ pub(crate) fn postgres_store_options_from_profile(
|
||||
|
||||
/// Connects to PostgreSQL without reapplying schemas initialized at application startup.
|
||||
pub(crate) async fn connect_postgres_store(
|
||||
profile: &kb_config::ProfileConfig,
|
||||
) -> std::result::Result<kb_store::PostgresStore, std::string::String> {
|
||||
profile: &ks_config::ProfileConfig,
|
||||
) -> std::result::Result<ks_store::PostgresStore, std::string::String> {
|
||||
if !profile.database.enabled {
|
||||
return std::result::Result::Err(std::string::String::from(
|
||||
"database configuration is disabled in the active profile",
|
||||
@@ -62,7 +62,7 @@ pub(crate) async fn connect_postgres_store(
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()),
|
||||
};
|
||||
options.auto_initialize_schema = false;
|
||||
let store_result = kb_store::PostgresStore::connect(options).await;
|
||||
let store_result = ks_store::PostgresStore::connect(options).await;
|
||||
return match store_result {
|
||||
std::result::Result::Ok(store) => std::result::Result::Ok(store),
|
||||
std::result::Result::Err(error) => std::result::Result::Err(error.to_string()),
|
||||
@@ -71,7 +71,7 @@ pub(crate) async fn connect_postgres_store(
|
||||
|
||||
/// Converts store table diagnostics to the UI payload shape.
|
||||
pub(crate) fn table_snapshot_from_pg(
|
||||
value: &kb_store::PostgresTableDiagnostics,
|
||||
value: &ks_store::PostgresTableDiagnostics,
|
||||
) -> crate::DemoSqlTableSnapshot {
|
||||
let row_count = match &value.statistics {
|
||||
std::option::Option::Some(statistics) => std::option::Option::Some(statistics.row_count),
|
||||
@@ -103,7 +103,7 @@ pub(crate) fn table_snapshot_from_pg(
|
||||
|
||||
/// Converts many table diagnostics to UI payloads.
|
||||
pub(crate) fn table_snapshots_from_pg(
|
||||
values: &[kb_store::PostgresTableDiagnostics],
|
||||
values: &[ks_store::PostgresTableDiagnostics],
|
||||
) -> std::vec::Vec<crate::DemoSqlTableSnapshot> {
|
||||
let mut output = std::vec::Vec::new();
|
||||
for value in values {
|
||||
@@ -169,7 +169,7 @@ pub(crate) async fn initialize_postgres_schema_for_startup(
|
||||
);
|
||||
}
|
||||
tracing::debug!(target: crate::TRACING_TARGET, dsn = masked_dsn.as_str(), "start PostgreSQL schema initialization");
|
||||
let store_result = kb_store::PostgresStore::connect(options).await;
|
||||
let store_result = ks_store::PostgresStore::connect(options).await;
|
||||
let store = match store_result {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => {
|
||||
@@ -218,8 +218,8 @@ pub(crate) fn debug_status<T: std::fmt::Debug>(value: T) -> std::string::String
|
||||
|
||||
fn emit_sql_startup_table_report(
|
||||
splash_window: &tauri::WebviewWindow,
|
||||
before_tables: &[kb_store::PostgresTableDiagnostics],
|
||||
after_tables: &[kb_store::PostgresTableDiagnostics],
|
||||
before_tables: &[ks_store::PostgresTableDiagnostics],
|
||||
after_tables: &[ks_store::PostgresTableDiagnostics],
|
||||
) {
|
||||
let mut created_count = 0_u32;
|
||||
let mut existing_count = 0_u32;
|
||||
@@ -268,7 +268,7 @@ fn emit_sql_startup_table_report(
|
||||
}
|
||||
|
||||
fn table_exists_in(
|
||||
tables: &[kb_store::PostgresTableDiagnostics],
|
||||
tables: &[ks_store::PostgresTableDiagnostics],
|
||||
table_name: &str,
|
||||
) -> std::option::Option<bool> {
|
||||
for table in tables {
|
||||
|
||||
Reference in New Issue
Block a user