persistence.rs 713 B

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