mod.rs 759 B

1234567891011121314151617181920212223242526
  1. pub mod delta_migration;
  2. pub mod rev_sqlite;
  3. use crate::services::migration::DocumentMigration;
  4. use crate::DocumentDatabase;
  5. use flowy_error::FlowyResult;
  6. use std::sync::Arc;
  7. pub struct DocumentPersistence {
  8. pub database: Arc<dyn DocumentDatabase>,
  9. }
  10. impl DocumentPersistence {
  11. pub fn new(database: Arc<dyn DocumentDatabase>) -> Self {
  12. Self { database }
  13. }
  14. #[tracing::instrument(level = "trace", skip_all, err)]
  15. pub fn initialize(&self, user_id: &str) -> FlowyResult<()> {
  16. let migration = DocumentMigration::new(user_id, self.database.clone());
  17. if let Err(e) = migration.run_v1_migration() {
  18. tracing::error!("[Document Migration]: run v1 migration failed: {:?}", e);
  19. }
  20. Ok(())
  21. }
  22. }