sqflite_migrator_plus 0.0.1
sqflite_migrator_plus: ^0.0.1 copied to clipboard
Managing your SQFLITE migrations made a breeze in Flutter.
sqflite_migrator_plus ๐ฆ #
Managing your migrations with sqflite made a breeze in Flutter.
๐ Recursos #
โ Create and update your table structures incrementally โ Easy table maintenance with no worries
๐ Instalaรงรฃo #
Add this dependecies to you pubspec.yaml file:
dependencies:
sqflite: ^2.4.1
sqflite_migrator_plus: ^0.0.1
Then run the command:
flutter pub get
๐ How to use it? #
Create your migrations #
import 'package:sqflite_migrator_plus/sqflite_migrator_plus.dart';
// create_table_products
class 202505091026_CreateTableProducts extends MigrationPlus {
@override
Future<void> execute(Database db) async {
await db.execute('''
CREATE TABLE products (
id INTEGER PRIMARY KEY AUTOINCREMENT,
product_name TEXT
)
''');
}
}
// add_price_to_products
class 202505101415_AddPriceToProducts extends MigrationPlus {
@override
Future<void> execute(Database db) async {
await db.execute('ALTER TABLE products ADD COLUMN price REAL DEFAULT 0');
}
}
final List<MigrationPlus> migrations = [
202505091026_CreateTableProducts(),
202505101415_AddPriceToProducts(),
];
Initialize your DB #
final dbMigratorInitializer = DbMigratorInitializer(dbName: "app_database.db", migrations: migrations);
final Database db = await dbMigratorInitializer.openAndRunMigrations();
Access your tables as usual #
await db.insert("products", {"product_name": "Smartphone", "price": 849.99});
List<Map<String, dynamic>> products = await db.query("products");
print(products);
Smart and easy #
๐น Don't loose your data on app updates ๐น Update your table schemas programmatically ๐น Runs needed migrtations only
Contributions #
๐น Make a repository fork ๐น Create a branch: git checkout -b my-branch ๐น Make a commit with your changes: git add . && git commit -m "Describe your feature" ๐น Upload your changes: git push origin my-branch ๐น Then create a Pull Request
License #
This project is licensed under MIT License - Read the file LICENSE.
๐ Links รteis #
Sqflite Docs GitHub Repository