sqflite_migration
0.3.0, released 6 years ago by flutterings.dev
Library to run SQLite migrations with sqflite in Flutter
What it does
It lets you define an initial schema and a list of migration scripts that are executed when opening a database. The helper opens the database, runs the init script if needed, then applies each migration in order.
AI-written summary of version 0.3.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to evolve a local SQLite schema over app releases
- You already use sqflite and want a simple migration helper
Skip it when
- You prefer a code‑generation based migration tool
- You need advanced migration features like version rollback or complex schema diff
Strengths
- Simple API, no code generation
- Supports null‑safety
- Works with existing sqflite code
Weaknesses
- Limited to raw SQL scripts, no schema diff
- No automatic migration generation
- No support for downgrades
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add dependency and import package, then call openDatabaseWithMigration with a MigrationConfig
import 'package:sqflite_migration/sqflite_migration.dart';
final config = MigrationConfig(
initializationScript: [
'''create table _todo_list (id integer primary key autoincrement, alias text not null)''',
],
migrationScripts: [
'''alter table _task add column done integer default 0;''',
],
);
Future<Database> open() async {
final path = join(await getDatabasesPath(), 'test.db');
return await openDatabaseWithMigration(path, config);
}
Alternatives
Packages that do the same job and could replace sqflite_migration.
- drift
Provides schema migration with code generation and type safety
99Compare - sqflite_common
Core sqflite implementation, but no migration helper
93Compare
Works with
Packages commonly used together with sqflite_migration: ones it builds on, ones built on it, and its own family.