Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flutterings/sqflite_migration
Library to manage sqlite db migrations.
https://github.com/flutterings/sqflite_migration
dart dartla database-migrations flutter mobile sqflite sqflite-database sqlite sqlite-database
Last synced: about 18 hours ago
JSON representation
Library to manage sqlite db migrations.
- Host: GitHub
- URL: https://github.com/flutterings/sqflite_migration
- Owner: flutterings
- License: other
- Created: 2019-03-02T21:10:05.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-27T16:47:52.000Z (over 3 years ago)
- Last Synced: 2024-06-21T08:13:55.676Z (5 months ago)
- Topics: dart, dartla, database-migrations, flutter, mobile, sqflite, sqflite-database, sqlite, sqlite-database
- Language: Dart
- Homepage: https://efthymis.com/migrating-a-mobile-database-in-flutter-sqlite/
- Size: 22.5 KB
- Stars: 46
- Watchers: 6
- Forks: 18
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/flutterings/sqflite_migration.svg?branch=master)](https://travis-ci.org/flutterings/sqflite_migration)
[![codecov](https://codecov.io/gh/flutterings/sqflite_migration/branch/master/graph/badge.svg)](https://codecov.io/gh/flutterings/sqflite_migration)# Migrate your mobile sqlite database
Library to manage sqlite db migrations using [sqflite](https://pub.dartlang.org/packages/sqflite) plugin.
## Getting Started
```dart
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 open() async {
final databasesPath = await getDatabasesPath();
final path = join(databasesPath, 'test.db');
return await openDatabaseWithMigration(path, config);
}
```