Skip to content

Commit

Permalink
zcash_client_sqlite: Make migration dependencies easier to track.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Aug 21, 2024
1 parent e4b3fb2 commit b1cb8be
Show file tree
Hide file tree
Showing 27 changed files with 88 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::shardtree_support;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xeeec0d0d_fee0_4231_8c68_5f3a7c7c2245);

const DEPENDENCIES: [Uuid; 1] = [shardtree_support::MIGRATION_ID];
const DEPENDENCIES: &[Uuid] = &[shardtree_support::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
Expand All @@ -24,7 +24,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
DEPENDENCIES.into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down Expand Up @@ -91,7 +91,7 @@ mod tests {
init_wallet_db_internal(
&mut db_data,
Some(Secret::new(seed_bytes.clone())),
&DEPENDENCIES,
DEPENDENCIES,
false,
)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ use crate::wallet::init::WalletMigrationError;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x282fad2e_8372_4ca0_8bed_71821320909f);

const DEPENDENCIES: &[Uuid] = &[
add_utxo_account::MIGRATION_ID,
sent_notes_to_internal::MIGRATION_ID,
];

pub(crate) struct Migration;

impl schemer::Migration for Migration {
Expand All @@ -26,12 +31,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
[
add_utxo_account::MIGRATION_ID,
sent_notes_to_internal::MIGRATION_ID,
]
.into_iter()
.collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ use {
/// This migration adds an account identifier column to the UTXOs table.
pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x761884d6_30d8_44ef_b204_0b82551c4ca1);

const DEPENDENCIES: &[Uuid] = &[utxos_table::MIGRATION_ID, addresses_table::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) _params: P,
}
Expand All @@ -38,9 +40,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[utxos_table::MIGRATION_ID, addresses_table::MIGRATION_ID]
.into_iter()
.collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ use super::ufvk_support;
/// the `accounts` table.
pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xd956978c_9c87_4d6e_815d_fb8f088d094c);

const DEPENDENCIES: &[Uuid] = &[ufvk_support::MIGRATION_ID];

pub(crate) struct Migration<P: consensus::Parameters> {
pub(crate) params: P,
}
Expand All @@ -30,7 +32,7 @@ impl<P: consensus::Parameters> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[ufvk_support::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use crate::{wallet::init::WalletMigrationError, UA_ORCHARD, UA_TRANSPARENT};

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x604349c7_5ce5_4768_bea6_12d106ccda93);

const DEPENDENCIES: &[Uuid] = &[orchard_received_notes::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
}
Expand All @@ -25,7 +27,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[orchard_received_notes::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::utxos_to_txos;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x0e1d4274_1f8e_44e2_909d_689a4bc2967b);

const DEPENDENCIES: [Uuid; 1] = [utxos_to_txos::MIGRATION_ID];
const DEPENDENCIES: &[Uuid] = &[utxos_to_txos::MIGRATION_ID];

#[allow(dead_code)]
pub(super) struct Migration<P> {
Expand All @@ -29,7 +29,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
DEPENDENCIES.into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down Expand Up @@ -210,7 +210,7 @@ mod tests {
init_wallet_db_internal(
&mut db_data,
Some(Secret::new(seed0.clone())),
&super::DEPENDENCIES,
super::DEPENDENCIES,
false,
)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ pub(crate) struct Migration<P: consensus::Parameters> {
pub(super) params: P,
}

const DEPENDENCIES: &[Uuid] = &[
receiving_key_scopes::MIGRATION_ID,
add_account_birthdays::MIGRATION_ID,
v_transactions_note_uniqueness::MIGRATION_ID,
wallet_summaries::MIGRATION_ID,
];

impl<P: consensus::Parameters> schemer::Migration for Migration<P> {
fn id(&self) -> Uuid {
MIGRATION_ID
}

fn dependencies(&self) -> HashSet<Uuid> {
[
receiving_key_scopes::MIGRATION_ID,
add_account_birthdays::MIGRATION_ID,
v_transactions_note_uniqueness::MIGRATION_ID,
wallet_summaries::MIGRATION_ID,
]
.into_iter()
.collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use super::received_notes_nullable_nf;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xe2d71ac5_6a44_4c6b_a9a0_6d0a79d355f1);

const DEPENDENCIES: &[Uuid] = &[received_notes_nullable_nf::MIGRATION_ID];

pub(super) struct Migration;

impl schemer::Migration for Migration {
Expand All @@ -21,9 +23,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
[received_notes_nullable_nf::MIGRATION_ID]
.into_iter()
.collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use crate::wallet::{init::WalletMigrationError, pool_code};

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x51d7a273_aa19_4109_9325_80e4a5545048);

const DEPENDENCIES: &[Uuid] = &[full_account_ids::MIGRATION_ID];

pub(super) struct Migration;

impl schemer::Migration for Migration {
Expand All @@ -20,7 +22,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
[full_account_ids::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ use crate::wallet::{chain_tip_height, init::WalletMigrationError, scanning::prio

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x3a6487f7_e068_42bb_9d12_6bb8dbe6da00);

const DEPENDENCIES: &[Uuid] = &[shardtree_support::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
}
Expand All @@ -25,7 +27,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[shardtree_support::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use crate::wallet::init::WalletMigrationError;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xbdcdcedc_7b29_4f1c_8307_35f937f0d32a);

const DEPENDENCIES: &[Uuid] = &[v_transactions_net::MIGRATION_ID];

pub(crate) struct Migration;

impl schemer::Migration for Migration {
Expand All @@ -21,7 +23,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
[v_transactions_net::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ use crate::{

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xee89ed2b_c1c2_421e_9e98_c1e3e54a7fc2);

const DEPENDENCIES: &[Uuid] = &[shardtree_support::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
}
Expand All @@ -48,7 +50,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[shardtree_support::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use super::received_notes_nullable_nf;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x7029b904_6557_4aa1_9da5_6904b65d2ba5);

const DEPENDENCIES: &[Uuid] = &[received_notes_nullable_nf::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
}
Expand All @@ -29,9 +31,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[received_notes_nullable_nf::MIGRATION_ID]
.into_iter()
.collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use crate::wallet::init::WalletMigrationError;
/// This migration adds the `to_account` field to the `sent_notes` table.
pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x0ddbe561_8259_4212_9ab7_66fdc4a74e1d);

const DEPENDENCIES: &[Uuid] = &[ufvk_support::MIGRATION_ID];

pub(super) struct Migration;

impl schemer::Migration for Migration {
Expand All @@ -21,7 +23,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
[ufvk_support::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ use crate::{

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x7da6489d_e835_4657_8be5_f512bcce6cbf);

const DEPENDENCIES: &[Uuid] = &[received_notes_nullable_nf::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
}
Expand All @@ -43,9 +45,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[received_notes_nullable_nf::MIGRATION_ID]
.into_iter()
.collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use super::full_account_ids;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0x07610aac_b0e3_4ba8_aaa6_cda606f0fd7b);

const DEPENDENCIES: [Uuid; 1] = [full_account_ids::MIGRATION_ID];
const DEPENDENCIES: &[Uuid] = &[full_account_ids::MIGRATION_ID];

#[allow(dead_code)]
pub(super) struct Migration;
Expand All @@ -23,7 +23,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
DEPENDENCIES.into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::ephemeral_addresses;

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xfec02b61_3988_4b4f_9699_98977fac9e7f);

const DEPENDENCIES: [Uuid; 1] = [ephemeral_addresses::MIGRATION_ID];
const DEPENDENCIES: &[Uuid] = &[ephemeral_addresses::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
Expand All @@ -26,7 +26,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
DEPENDENCIES.into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down Expand Up @@ -170,7 +170,7 @@ mod tests {
init_wallet_db_internal(
&mut db_data,
Some(Secret::new(seed_bytes.clone())),
&DEPENDENCIES,
DEPENDENCIES,
false,
)
.unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ use crate::{

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xbe57ef3b_388e_42ea_97e2_678dafcf9754);

const DEPENDENCIES: &[Uuid] = &[initial_setup::MIGRATION_ID];

pub(super) struct Migration<P> {
pub(super) params: P,
pub(super) seed: Option<Rc<SecretVec<u8>>>,
Expand All @@ -38,7 +40,7 @@ impl<P> schemer::Migration for Migration<P> {
}

fn dependencies(&self) -> HashSet<Uuid> {
[initial_setup::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ use crate::wallet::init::{migrations::initial_setup, WalletMigrationError};

pub(super) const MIGRATION_ID: Uuid = Uuid::from_u128(0xa2e0ed2e_8852_475e_b0a4_f154b15b9dbe);

const DEPENDENCIES: &[Uuid] = &[initial_setup::MIGRATION_ID];

pub(super) struct Migration;

impl schemer::Migration for Migration {
Expand All @@ -18,7 +20,7 @@ impl schemer::Migration for Migration {
}

fn dependencies(&self) -> HashSet<Uuid> {
[initial_setup::MIGRATION_ID].into_iter().collect()
DEPENDENCIES.iter().copied().collect()
}

fn description(&self) -> &'static str {
Expand Down
Loading

0 comments on commit b1cb8be

Please sign in to comment.