zcash_client_sqlite: Migrate to `schemerz 0.2`

This commit is contained in:
Jack Grigg 2024-10-16 20:49:42 +00:00
parent 3d6b6e8f09
commit 2c5e198586
36 changed files with 49 additions and 46 deletions

9
Cargo.lock generated
View File

@ -3696,11 +3696,12 @@ dependencies = [
[[package]]
name = "schemerz"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ef620a7502b464270648afce68f6e736a87380854b3e4a6debd5a42e3e88c954"
checksum = "3e82960ac11ccabd77d53c933532612079e01205b5873ec5095f4b3426493434"
dependencies = [
"daggy",
"indexmap 1.9.3",
"log",
"thiserror",
"uuid",
@ -3708,9 +3709,9 @@ dependencies = [
[[package]]
name = "schemerz-rusqlite"
version = "0.290.0"
version = "0.291.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51240765dba899b938627b7e0e8fdceb211fe2b2310385cf9ddc9c2a733d671d"
checksum = "2d63d986477f0882e30bf36870038fff9d4e9c6705e84d66b1407543722f378b"
dependencies = [
"rusqlite",
"schemerz",

View File

@ -124,8 +124,8 @@ subtle = "2.2.3"
# CocoaPods, due to being bound to React Native. We need to ensure that the SQLite
# version required for `rusqlite` is a version that is available through CocoaPods.
rusqlite = { version = "0.29.0", features = ["bundled"] }
schemerz = "0.1"
schemerz-rusqlite = "0.290"
schemerz = "0.2"
schemerz-rusqlite = "0.291"
time = "0.3.22"
uuid = "1.1"

View File

@ -77,15 +77,15 @@ user-login = "nuttycom"
user-name = "Kris Nuttycombe"
[[publisher.schemerz]]
version = "0.1.0"
when = "2024-10-15"
version = "0.2.0"
when = "2024-10-16"
user-id = 6289
user-login = "str4d"
user-name = "Jack Grigg"
[[publisher.schemerz-rusqlite]]
version = "0.290.0"
when = "2024-10-15"
version = "0.291.0"
when = "2024-10-16"
user-id = 6289
user-login = "str4d"
user-name = "Jack Grigg"

View File

@ -55,13 +55,15 @@ pub fn init_cache_database(db_cache: &BlockDb) -> Result<(), rusqlite::Error> {
/// init_blockmeta_db(&mut db).unwrap();
/// ```
#[cfg(feature = "unstable")]
pub fn init_blockmeta_db(db: &mut FsBlockDb) -> Result<(), MigratorError<rusqlite::Error>> {
pub fn init_blockmeta_db(
db: &mut FsBlockDb,
) -> Result<(), MigratorError<uuid::Uuid, rusqlite::Error>> {
let adapter = RusqliteAdapter::new(&mut db.conn, Some("schemer_migrations".to_string()));
adapter.init().expect("Migrations table setup succeeds.");
let mut migrator = Migrator::new(adapter);
migrator
.register_multiple(migrations::blockmeta::all_migrations())
.register_multiple(migrations::blockmeta::all_migrations().into_iter())
.expect("Migration registration should have been successful.");
migrator.up(None)?;
Ok(())

View File

@ -24,7 +24,7 @@ pub mod init {
migration!(
Migration,
&format!("{}", MIGRATION_ID),
MIGRATION_ID,
[],
"Initialize the cachemeta database."
);

View File

@ -308,7 +308,7 @@ fn sqlite_client_error_to_wallet_migration_error(e: SqliteClientError) -> Wallet
pub fn init_wallet_db<P: consensus::Parameters + 'static>(
wdb: &mut WalletDb<rusqlite::Connection, P>,
seed: Option<SecretVec<u8>>,
) -> Result<(), MigratorError<WalletMigrationError>> {
) -> Result<(), MigratorError<Uuid, WalletMigrationError>> {
init_wallet_db_internal(wdb, seed, &[], true)
}
@ -317,7 +317,7 @@ fn init_wallet_db_internal<P: consensus::Parameters + 'static>(
seed: Option<SecretVec<u8>>,
target_migrations: &[Uuid],
verify_seed_relevance: bool,
) -> Result<(), MigratorError<WalletMigrationError>> {
) -> Result<(), MigratorError<Uuid, WalletMigrationError>> {
let seed = seed.map(Rc::new);
verify_sqlite_version_compatibility(&wdb.conn).map_err(MigratorError::Adapter)?;
@ -335,7 +335,7 @@ fn init_wallet_db_internal<P: consensus::Parameters + 'static>(
let mut migrator = Migrator::new(adapter);
migrator
.register_multiple(migrations::all_migrations(&wdb.params, seed.clone()))
.register_multiple(migrations::all_migrations(&wdb.params, seed.clone()).into_iter())
.expect("Wallet migration registration should have been successful.");
if target_migrations.is_empty() {
migrator.up(None)?;

View File

@ -18,7 +18,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -25,7 +25,7 @@ const DEPENDENCIES: &[Uuid] = &[
pub(crate) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -33,7 +33,7 @@ pub(super) struct Migration<P> {
pub(super) _params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -25,7 +25,7 @@ pub(crate) struct Migration<P: consensus::Parameters> {
pub(crate) params: P,
}
impl<P: consensus::Parameters> schemerz::Migration for Migration<P> {
impl<P: consensus::Parameters> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -21,7 +21,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -21,7 +21,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -20,7 +20,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -33,7 +33,7 @@ const DEPENDENCIES: &[Uuid] = &[
wallet_summaries::MIGRATION_ID,
];
impl<P: consensus::Parameters> schemerz::Migration for Migration<P> {
impl<P: consensus::Parameters> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -11,7 +11,7 @@ pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xbc4f5e57_d600_4b6c_990f_
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -17,7 +17,7 @@ const DEPENDENCIES: &[Uuid] = &[received_notes_nullable_nf::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -16,7 +16,7 @@ const DEPENDENCIES: &[Uuid] = &[full_account_ids::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -21,7 +21,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -15,7 +15,7 @@ const DEPENDENCIES: &[Uuid] = &[v_transactions_net::MIGRATION_ID];
pub(crate) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -43,7 +43,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -25,7 +25,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -15,7 +15,7 @@ const DEPENDENCIES: &[Uuid] = &[ufvk_support::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -38,7 +38,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -15,7 +15,7 @@ const DEPENDENCIES: &[Uuid] = &[full_account_ids::MIGRATION_ID];
#[allow(dead_code)]
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -12,7 +12,7 @@ const DEPENDENCIES: &[Uuid] = &[tx_retrieval_queue::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -29,7 +29,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -33,7 +33,7 @@ pub(super) struct Migration<P> {
pub(super) seed: Option<Rc<SecretVec<u8>>>,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -12,7 +12,7 @@ const DEPENDENCIES: &[Uuid] = &[initial_setup::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -13,7 +13,7 @@ const DEPENDENCIES: &[Uuid] = &[orchard_received_notes::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -20,7 +20,7 @@ pub(super) struct Migration<P> {
pub(super) params: P,
}
impl<P> schemerz::Migration for Migration<P> {
impl<P> schemerz::Migration<Uuid> for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -16,7 +16,7 @@ const DEPENDENCIES: &[Uuid] = &[add_transaction_views::MIGRATION_ID];
pub(crate) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -16,7 +16,7 @@ const DEPENDENCIES: &[Uuid] = &[v_transactions_shielding_balance::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -16,7 +16,7 @@ const DEPENDENCIES: &[Uuid] = &[v_tx_outputs_use_legacy_false::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -16,7 +16,7 @@ const DEPENDENCIES: &[Uuid] = &[sapling_memo_consistency::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -17,7 +17,7 @@ const DEPENDENCIES: &[Uuid] = &[v_transactions_transparent_history::MIGRATION_ID
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}

View File

@ -15,7 +15,7 @@ const DEPENDENCIES: &[Uuid] = &[v_sapling_shard_unscanned_ranges::MIGRATION_ID];
pub(super) struct Migration;
impl schemerz::Migration for Migration {
impl schemerz::Migration<Uuid> for Migration {
fn id(&self) -> Uuid {
MIGRATION_ID
}