bitwarden_encrypted_migrator/
migration.rs1use bitwarden_core::{Client, FromClient};
7use tracing::{Instrument, info_span};
8
9use crate::migrations::account_recovery_v2_upgrade::AccountRecoveryV2UpgradeMigration;
10
11pub(crate) enum Migration {
15 AccountRecoveryV2Upgrade(AccountRecoveryV2UpgradeMigration),
16}
17
18impl Migration {
19 pub(crate) fn all(client: &Client) -> Vec<Migration> {
21 vec![Migration::AccountRecoveryV2Upgrade(
22 AccountRecoveryV2UpgradeMigration::from_client(client),
23 )]
24 }
25
26 pub(crate) fn name(&self) -> &'static str {
27 match self {
28 Migration::AccountRecoveryV2Upgrade(_) => "account_recovery_v2_upgrade",
29 }
30 }
31
32 pub(crate) async fn run(&self) {
34 match self {
35 Migration::AccountRecoveryV2Upgrade(migration) => migration.run().await,
36 }
37 }
38}
39
40pub(crate) async fn run_migrations(migrations: &[Migration]) {
42 for migration in migrations {
43 migration
44 .run()
45 .instrument(info_span!("encrypted_migration", name = migration.name()))
46 .await;
47 }
48}