From 9a737ef57f0f82c947059ce6a9f1bd3d91c51dc5 Mon Sep 17 00:00:00 2001 From: SinuS Von SifriduS Date: Mon, 21 Sep 2026 11:19:55 +0200 Subject: [PATCH] 0.3.16-pre.3.fix.1 --- crates/ksp-store-postgres-lib/src/lib.rs | 2 +- .../src/migration_v003.rs | 40 ++++--------------- .../ksp-store-postgres-lib/src/schema_v003.rs | 23 ++++------- .../unit_tests/migration_v003.rs | 6 +-- 4 files changed, 17 insertions(+), 54 deletions(-) diff --git a/crates/ksp-store-postgres-lib/src/lib.rs b/crates/ksp-store-postgres-lib/src/lib.rs index fce60d9..015d759 100644 --- a/crates/ksp-store-postgres-lib/src/lib.rs +++ b/crates/ksp-store-postgres-lib/src/lib.rs @@ -102,9 +102,9 @@ pub(crate) use self::schema::inspect_resource; pub(crate) use self::schema::managed_schema_objects_exist; pub(crate) use self::schema::verify_v001_external_compatibility; pub(crate) use self::schema::verify_v002_external_compatibility; +pub(crate) use self::schema_v003::V003_RESOURCES; pub(crate) use self::schema_v003::V003SchemaResource; pub(crate) use self::schema_v003::V003SchemaResourceState; -pub(crate) use self::schema_v003::V003_RESOURCES; pub(crate) use self::schema_v003::inspect_v003_resource; pub(crate) use self::schema_v003::verify_v003_external_compatibility; diff --git a/crates/ksp-store-postgres-lib/src/migration_v003.rs b/crates/ksp-store-postgres-lib/src/migration_v003.rs index dcf38d4..9d6bb37 100644 --- a/crates/ksp-store-postgres-lib/src/migration_v003.rs +++ b/crates/ksp-store-postgres-lib/src/migration_v003.rs @@ -45,10 +45,7 @@ pub(crate) async fn bootstrap( migration_lock_timeout: std::time::Duration, ) -> std::result::Result<(), crate::PostgresBackendError> { if crate::legacy_current_migration_version() != 2 { - return std::result::Result::Err(crate::PostgresBackendError::new( - crate::PostgresBackendErrorKind::MigrationMismatch, - "v003_legacy_registry_version", - )); + return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationMismatch, "v003_legacy_registry_version")); } let metadata_result = metadata_exists_client(client).await; let metadata_preexisting = match metadata_result { @@ -70,15 +67,7 @@ pub(crate) async fn bootstrap( return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::SchemaNewer, "history_newer")); } if legacy_bootstrap_required(latest_before) { - let legacy_result = crate::legacy_bootstrap( - client, - network, - schema_autocreate, - schema_autoupdate, - migration_timeout, - migration_lock_timeout, - ) - .await; + let legacy_result = crate::legacy_bootstrap(client, network, schema_autocreate, schema_autoupdate, migration_timeout, migration_lock_timeout).await; if let std::result::Result::Err(error) = legacy_result { if error.kind() != crate::PostgresBackendErrorKind::SchemaNewer { return std::result::Result::Err(error); @@ -199,10 +188,7 @@ async fn acquire_advisory_lock( let acquired = match acquired_result { std::result::Result::Ok(value) => value, std::result::Result::Err(_) => { - return std::result::Result::Err(crate::PostgresBackendError::new( - crate::PostgresBackendErrorKind::MigrationFailed, - "migration_lock_decode", - )); + return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationFailed, "migration_lock_decode")); }, }; if acquired { @@ -301,10 +287,7 @@ async fn verify_or_apply_v003_resources( return std::result::Result::Err(schema_autoupdate_disabled_error()); } if !applied_history && !allow_v003_apply { - return std::result::Result::Err(crate::PostgresBackendError::new( - crate::PostgresBackendErrorKind::MigrationFailed, - "migration_pending", - )); + return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationFailed, "migration_pending")); } if applied_history && !resource.repair_existing { return std::result::Result::Err(crate::PostgresBackendError::new( @@ -356,10 +339,7 @@ async fn validate_store_identity( let (singleton, stored_network) = match (singleton_result, network_result) { (std::result::Result::Ok(singleton), std::result::Result::Ok(stored_network)) => (singleton, stored_network), _ => { - return std::result::Result::Err(crate::PostgresBackendError::new( - crate::PostgresBackendErrorKind::MigrationMismatch, - "store_identity_decode", - )); + return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationMismatch, "store_identity_decode")); }, }; if singleton != 1 || stored_network != network.as_str() { @@ -400,9 +380,7 @@ async fn latest_version_client(client: &deadpool_postgres::Client) -> std::resul }; } -async fn load_history( - transaction: &deadpool_postgres::Transaction<'_>, -) -> std::result::Result, crate::PostgresBackendError> { +async fn load_history(transaction: &deadpool_postgres::Transaction<'_>) -> std::result::Result, crate::PostgresBackendError> { let result = transaction.query(HISTORY_LOAD_SQL, &[]).await; let rows = match result { std::result::Result::Ok(value) => value, @@ -431,11 +409,7 @@ fn validate_history(history: &[AppliedMigration]) -> std::result::Result V003SchemaResource { - return V003SchemaResource { id, object: V003SchemaObjectContract::Table(TableContract { columns, name }), repair_existing: true, sql }; + return V003SchemaResource { + id, + object: V003SchemaObjectContract::Table(TableContract { columns, name }), + repair_existing: true, + sql, + }; } -const fn constraint_resource( - id: &'static str, - kind: &'static str, - name: &'static str, - table: &'static str, - sql: &'static str, -) -> V003SchemaResource { +const fn constraint_resource(id: &'static str, kind: &'static str, name: &'static str, table: &'static str, sql: &'static str) -> V003SchemaResource { return V003SchemaResource { id, object: V003SchemaObjectContract::Constraint(ConstraintContract { kind, name, table }), @@ -325,13 +324,7 @@ const fn constraint_resource( }; } -const fn index_resource( - id: &'static str, - key_fragment: &'static str, - name: &'static str, - table: &'static str, - sql: &'static str, -) -> V003SchemaResource { +const fn index_resource(id: &'static str, key_fragment: &'static str, name: &'static str, table: &'static str, sql: &'static str) -> V003SchemaResource { return V003SchemaResource { id, object: V003SchemaObjectContract::Index(IndexContract { diff --git a/crates/ksp-store-postgres-lib/unit_tests/migration_v003.rs b/crates/ksp-store-postgres-lib/unit_tests/migration_v003.rs index d783fb6..deef821 100644 --- a/crates/ksp-store-postgres-lib/unit_tests/migration_v003.rs +++ b/crates/ksp-store-postgres-lib/unit_tests/migration_v003.rs @@ -61,10 +61,7 @@ fn pre_003_v003_history_rejects_divergence_and_future_versions() { applied(4, "future", "future"), ]; let direct_future_result = super::validate_history(&direct_future); - assert_eq!( - direct_future_result.err().map(|value| return value.kind()), - std::option::Option::Some(crate::PostgresBackendErrorKind::SchemaNewer), - ); + assert_eq!(direct_future_result.err().map(|value| return value.kind()), std::option::Option::Some(crate::PostgresBackendErrorKind::SchemaNewer),); return; } @@ -84,4 +81,3 @@ fn pre_003_v003_bootstrap_uses_legacy_engine_only_before_v002_and_absorbs_comple assert!(!super::v003_apply_allowed(true, false)); return; } -