fix(migrations): adopt published ledgerless baseline
This commit is contained in:
1 parent
527efb510f
commit
2759fde81f
7 files changed
+572
-21
No files matched your search
@@ -325,6 +325,15 @@ pub(super) async fn validate_schema_fingerprint(
|
||||
.iter()
|
||||
.filter_map(|row| row.try_get::<String, _>("column_name").ok())
|
||||
.collect::<Vec<_>>();
|
||||
let required = required
|
||||
.iter()
|
||||
.copied()
|
||||
.filter(|column| {
|
||||
!(current_version == 1
|
||||
&& *table == "__crank_ext_migrations"
|
||||
&& *column == "checksum")
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if actual.len() != required.len()
|
||||
|| required
|
||||
.iter()
|
||||
@@ -337,6 +346,9 @@ pub(super) async fn validate_schema_fingerprint(
|
||||
if !relation_exists(connection, table).await? {
|
||||
continue;
|
||||
}
|
||||
if current_version == 1 && *table == "__crank_ext_migrations" && *column == "checksum" {
|
||||
continue;
|
||||
}
|
||||
let row = query(
|
||||
"select data_type, is_nullable from information_schema.columns
|
||||
where table_schema = current_schema() and table_name = $1 and column_name = $2",
|
||||
@@ -424,23 +436,25 @@ pub(super) async fn validate_schema_fingerprint(
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
}
|
||||
let required_indexes = [
|
||||
"mcp_transport_sessions_workspace_agent_idx",
|
||||
"mcp_transport_sessions_expires_at_idx",
|
||||
];
|
||||
for index in required_indexes {
|
||||
let present = query(
|
||||
"select exists (select 1 from pg_catalog.pg_indexes
|
||||
where schemaname = current_schema() and indexname = $1) as present",
|
||||
)
|
||||
.bind(index)
|
||||
.fetch_one(&mut *connection)
|
||||
.await
|
||||
.map_err(|_| MigrationError::storage("preflight.schema"))?
|
||||
.try_get::<bool, _>("present")
|
||||
.map_err(|_| MigrationError::storage("preflight.schema"))?;
|
||||
if !present {
|
||||
return Err(schema_error(current_version));
|
||||
if relation_exists(connection, "mcp_transport_sessions").await? {
|
||||
let required_indexes = [
|
||||
"mcp_transport_sessions_workspace_agent_idx",
|
||||
"mcp_transport_sessions_expires_at_idx",
|
||||
];
|
||||
for index in required_indexes {
|
||||
let present = query(
|
||||
"select exists (select 1 from pg_catalog.pg_indexes
|
||||
where schemaname = current_schema() and indexname = $1) as present",
|
||||
)
|
||||
.bind(index)
|
||||
.fetch_one(&mut *connection)
|
||||
.await
|
||||
.map_err(|_| MigrationError::storage("preflight.schema"))?
|
||||
.try_get::<bool, _>("present")
|
||||
.map_err(|_| MigrationError::storage("preflight.schema"))?;
|
||||
if !present {
|
||||
return Err(schema_error(current_version));
|
||||
}
|
||||
}
|
||||
}
|
||||
if current_version >= 3 {
|
||||
|
||||
Reference in new issue
Block a user