sqflite_migration 0.3.0 copy "sqflite_migration: ^0.3.0" to clipboard
sqflite_migration: ^0.3.0 copied to clipboard

A library to enable sqlite db migrations, using sqflite plugin.

Build Status codecov

Migrate your mobile sqlite database #

Library to manage sqlite db migrations using sqflite plugin.

Getting Started #

import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';
import 'package:sqflite_migration/sqflite_migration.dart';

final initialScript = [
  '''
create table _todo_list (
  id integer primary key autoincrement,
  alias text not null
  )
''',
  '''
create table _task (
  id integer primary key autoincrement,
  description text,
  todo_list_id integer not null,
  CONSTRAINT fk_todo_lists
    FOREIGN KEY (todo_list_id)
    REFERENCES _todo_list(id)
);
'''
];

final migrations = [
  '''
  alter table _task add column done integer default 0;
  '''
];

final config = MigrationConfig(initializationScript: initialScript, migrationScripts: migrations);

Future<Database> open() async {
 final databasesPath = await getDatabasesPath();
 final path = join(databasesPath, 'test.db');
 
 return await openDatabaseWithMigration(path, config);
}
22
likes
145
pub points
87%
popularity

Publisher

verified publisherflutterings.dev

A library to enable sqlite db migrations, using sqflite plugin.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, sqflite

More

Packages that depend on sqflite_migration