0.3.16-pre.3.fix.1

This commit is contained in:
2026-09-21 11:19:55 +02:00
parent 540b1bc305
commit 9a737ef57f
4 changed files with 17 additions and 54 deletions

View File

@@ -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;

View File

@@ -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<std::vec::Vec<AppliedMigration>, crate::PostgresBackendError> {
async fn load_history(transaction: &deadpool_postgres::Transaction<'_>) -> std::result::Result<std::vec::Vec<AppliedMigration>, 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<i64, cr
if history.len() < 3 {
return std::result::Result::Err(crate::PostgresBackendError::new(crate::PostgresBackendErrorKind::MigrationMismatch, "history_missing"));
}
let expected = [
(0_i64, "bootstrap", V000_CHECKSUM),
(1_i64, "raw_transaction", V001_CHECKSUM),
(2_i64, "raw_account_state", V002_CHECKSUM),
];
let expected = [(0_i64, "bootstrap", V000_CHECKSUM), (1_i64, "raw_transaction", V001_CHECKSUM), (2_i64, "raw_account_state", V002_CHECKSUM)];
for (index, (version, name, checksum)) in expected.iter().enumerate() {
let applied = &history[index];
if applied.version != *version || applied.name != *name || applied.checksum != *checksum {

View File

@@ -307,16 +307,15 @@ const fn column(
}
const fn table_resource(id: &'static str, name: &'static str, columns: &'static [ColumnContract], sql: &'static str) -> 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 {

View File

@@ -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;
}