FLUTTER ECOSYSTEM

MattiaPispisa/data_migration

오래된 데이터 구조의 버전을 최신 버전으로 업데이트하기 위해 일련의 마이그레이션을 적용하는 라이브러리입니다.

데이터 마이그레이션 프로젝트 이미지
Stars
2
Forks
0
최근 푸시(UTC)
2024. 12. 18.
프로젝트 상태
활성
Mattia GitHub avatar
GITHUB User

Mattia ↗

I have always been passionate about mobile development. I started with iOS and then transitioned to a hybrid approach.

MVLabsUdine, Italy공식 웹사이트 ↗
언어Dart

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 3 개

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

Data Migration

ci License: MIT coverage

A library for applying a series of migrations to update old versions of data structures to the most recent one.

Installation

dependencies:
  data_migration:

How to use

  1. Create your set of migration

    class CounterV1DataMigration implements DataMigration {
      const CounterV1DataMigration();
    
      @override
      int get fromVersion => 1;
    
      @override
      int get toVersion => 2;
    
      @override
      Future<dynamic> migrate(dynamic data) async {
        final counter = SimpleCounter(data as int);
        return counter.toJson();
      }
    }
    
    final migrator = DataMigrationManager(
      [
        CounterV1DataMigration(),
      ],
    );
    
  2. Apply migration on data

      final migrated1 = await _migrator.migrateIfNeeded(
         3,
         fromVersion: 1,
      );
    

Examples

In the example and tests, there are some examples of "data migration."