mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-21 22:54:49 +01:00
Changes
1. Fix migration to avoid re-running migration twice 2. Remove tokio dependency
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -21,14 +21,17 @@ pub async fn migrate<C: DatabaseExecutor>(
|
|||||||
|
|
||||||
// Apply each migration if it hasn’t been applied yet
|
// Apply each migration if it hasn’t 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();
|
||||||
|
|||||||
Reference in New Issue
Block a user