Closed jamespet77 closed 5 years ago
@jaumard
@linuxjet you already have the FomConnexion
https://github.com/Jaguar-dart/jaguar_orm/blob/feature/alter_sqflite/sqflite/lib/src/adapter.dart#L20 where you can pass directly an SQFlite instance, it's better to use that, if we start added onUpgrade, someone will after want onDowngrade and then another field and we'll have to proxy all the fields ^^
The FromConnexion is here if you need more configuration :)
what do you think. ?
Not exactly sure where you are headed with that, unless you just assume creating the Sqlite connection first manually and preform the upgrade process then passing the connection to the adapter?
Yes here is what I use:
final adapter = SqfliteAdapter.fromConnection(await openDatabase(file, version: databaseVersion, onUpgrade: (db, currentVersion, newVersion) async {
//do what you need on upgrade
}, onDowngrade: (db, currentVersion, newVersion) async {
//do what you need on downgrade
}, onCreate: (db, version) async {
//do what you need on create
}, onOpen: (db) async {
//do what you need on open
}));
ok. thx
It would be nice to have somewhat of an upgrade option for changing db table schema.
possibly change file https://github.com/Jaguar-dart/jaguar_orm/blob/feature/alter_sqflite/sqflite/lib/src/adapter.dart#L25
to:
/// Connects to the database Future connect({onUpgradeDB}) async {
if (_connection == null) {
_connection = await sqf.openDatabase(path, version: version,onUpgrade: onUpgradeDB);
}
}
This would open up the possibility to make table changes on startup when a db is upgraded.