1. Fix migration to avoid re-running migration twice
2. Remove tokio dependency
This commit is contained in:
Cesar Rodas
2025-07-25 11:18:31 -03:00
parent 034af74013
commit 1f85d0fd7a
2 changed files with 6 additions and 4 deletions

View File

@@ -22,7 +22,6 @@ async-trait.workspace = true
cdk-common = { workspace = true, features = ["test"] } cdk-common = { workspace = true, features = ["test"] }
bitcoin.workspace = true bitcoin.workspace = true
thiserror.workspace = true thiserror.workspace = true
tokio.workspace = true
tracing.workspace = true tracing.workspace = true
serde.workspace = true serde.workspace = true
serde_json.workspace = true serde_json.workspace = true

View File

@@ -21,14 +21,17 @@ pub async fn migrate<C: DatabaseExecutor>(
// Apply each migration if it hasnt been applied yet // Apply each migration if it hasnt been applied yet
for (name, sql) in migrations { for (name, sql) in migrations {
if let Some((prefix, _)) = name.split_once(['/', '\\']) { let basename = if let Some((prefix, basename)) = name.split_once(['/', '\\']) {
if prefix != db_prefix { if prefix != db_prefix {
continue; continue;
} }
} basename
} else {
name
};
let is_missing = query("SELECT name FROM migrations WHERE name = :name")? let is_missing = query("SELECT name FROM migrations WHERE name = :name")?
.bind("name", name) .bind("name", basename)
.pluck(conn) .pluck(conn)
.await? .await?
.is_none(); .is_none();