Search packages, repositories and app categories

Package detailsv1.0.0

data_migration

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

AndroidiOSWebmacOSWindowsLinux
30-day downloads
44
Likes
3
Pub points
150

Install package

flutter pub add data_migration

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The data_migration package provides a structured way to evolve data models across different versions by applying a sequence of migrations. It is designed to safely update outdated data structures to the latest schema, ensuring data integrity during app updates. Developers define migration steps that transform old data formats into new ones, making it ideal for apps with persistent local storage. The library supports multiple platforms and integrates seamlessly with Flutter applications.

Use cases

  • Updating local database schemas
  • Migrating user data between app versions
  • Maintaining backward compatibility
  • Handling schema changes in shared preferences
  • Automating data transformation on app startup
  • Supporting complex data model evolution

Key features

  • Versioned migration system
  • Safe data transformation
  • Extensible migration definitions
  • Cross-platform support
  • Simple API for defining migrations
  • Built-in error handling

Suitable for

  • Apps with persistent local data
  • Developers managing schema changes
  • Projects requiring backward compatibility
  • Teams using versioned data models
  • Flutter apps with evolving data structures

Considerations

  • Requires careful planning of migration steps
  • Manual definition of each migration
  • Potential performance impact with large datasets
  • Limited built-in validation
  • Not suitable for real-time sync scenarios
  • Depends on correct version tracking

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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."

Categories

Source repository

Projects using this package

No data available yet.