mirror of
https://github.com/aljazceru/cdk.git
synced 2025-12-18 21:25:09 +01:00
Apply suggestions from code review
Co-authored-by: thesimplekid <tsk@thesimplekid.com>
This commit is contained in:
@@ -21,13 +21,14 @@ 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 {
|
||||||
let basename = if let Some((prefix, basename)) = name.split_once(['/', '\\']) {
|
let basename = match name.split_once(['/', '\\']) {
|
||||||
if prefix != db_prefix {
|
Some((prefix, basename)) => {
|
||||||
continue;
|
if prefix != db_prefix {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
basename
|
||||||
}
|
}
|
||||||
basename
|
None => name,
|
||||||
} else {
|
|
||||||
name
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let is_missing = query("SELECT name FROM migrations WHERE name = :name")?
|
let is_missing = query("SELECT name FROM migrations WHERE name = :name")?
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ pub trait ResourceManager: Debug {
|
|||||||
|
|
||||||
/// Creates a new resource with a given config.
|
/// Creates a new resource with a given config.
|
||||||
///
|
///
|
||||||
/// If `stale` is every set to TRUE it is assumed the resource is no longer valid and it will be
|
/// If `stale` is ever set to TRUE it is assumed the resource is no longer valid and it will be
|
||||||
/// dropped.
|
/// dropped.
|
||||||
fn new_resource(
|
fn new_resource(
|
||||||
config: &Self::Config,
|
config: &Self::Config,
|
||||||
|
|||||||
@@ -176,9 +176,11 @@ impl Statement {
|
|||||||
} else {
|
} else {
|
||||||
let parts = split_sql_parts(sql)?;
|
let parts = split_sql_parts(sql)?;
|
||||||
|
|
||||||
let _ = cache.write().map(|mut cache| {
|
if let Ok(mut cache) = cache.write() {
|
||||||
cache.insert(sql.to_owned(), (parts.clone(), None));
|
cache.insert(sql.to_owned(), (parts.clone(), None));
|
||||||
});
|
} else {
|
||||||
|
tracing::warn!("Failed to acquire write lock for SQL statement cache");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
parts,
|
parts,
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ CREATE TABLE IF NOT EXISTS "proof" (
|
|||||||
amount INTEGER NOT NULL,
|
amount INTEGER NOT NULL,
|
||||||
keyset_id TEXT NOT NULL, -- no FK constraint here
|
keyset_id TEXT NOT NULL, -- no FK constraint here
|
||||||
secret TEXT NOT NULL,
|
secret TEXT NOT NULL,
|
||||||
c BLOBNOT NULL,
|
c BLOB NOT NULL,
|
||||||
witness TEXT,
|
witness TEXT,
|
||||||
state TEXT CHECK (state IN ('SPENT', 'PENDING', 'UNSPENT', 'RESERVED', 'UNKNOWN')) NOT NULL,
|
state TEXT CHECK (state IN ('SPENT', 'PENDING', 'UNSPENT', 'RESERVED', 'UNKNOWN')) NOT NULL,
|
||||||
quote_id TEXT,
|
quote_id TEXT,
|
||||||
|
|||||||
Reference in New Issue
Block a user