Skip to content

Commit f29bead

Browse files
committed
refactor: constrain hashing to MigrationDirectory related types
1 parent ab6c2ac commit f29bead

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

schema-engine/commands/src/migration_schema_cache.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::borrow::Borrow;
12
use std::collections::HashMap;
23
use std::collections::hash_map::DefaultHasher;
34
use std::hash::{Hash, Hasher};
@@ -22,7 +23,7 @@ impl MigrationSchemaCache {
2223
where
2324
F: FnOnce() -> Fut,
2425
Fut: std::future::Future<Output = Result<DatabaseSchema, E>>,
25-
T: Hash,
26+
T: Borrow<json_rpc::types::MigrationDirectory> + Hash,
2627
{
2728
let mut hasher = DefaultHasher::new();
2829
migration_directories.hash(&mut hasher);

schema-engine/connectors/schema-connector/src/migrations_directory.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
use crate::{checksum, ConnectorError, ConnectorResult};
99
use json_rpc::types::MigrationLockfile;
10-
use std::{error::Error, fmt::Display};
10+
use std::{borrow::Borrow, error::Error, fmt::Display};
1111
use tracing_error::SpanTrace;
1212
use user_facing_errors::schema_engine::ProviderSwitchedError;
1313

@@ -94,6 +94,12 @@ impl MigrationDirectory {
9494
}
9595
}
9696

97+
impl Borrow<json_rpc::types::MigrationDirectory> for MigrationDirectory {
98+
fn borrow(&self) -> &json_rpc::types::MigrationDirectory {
99+
&self.0
100+
}
101+
}
102+
97103
/// Error while reading a migration script.
98104
#[derive(Debug)]
99105
pub struct ReadMigrationScriptError(pub(crate) std::io::Error, pub SpanTrace, pub String);

0 commit comments

Comments
 (0)