Merge pull request #1819 from famedly/krille/create-missing-object-box
fix: Hotfix create missing objectbox
This commit is contained in:
commit
57625d0275
|
|
@ -19,12 +19,15 @@ class BoxCollection with ZoneTransactionMixin {
|
||||||
Object? sqfliteDatabase,
|
Object? sqfliteDatabase,
|
||||||
Object? sqfliteFactory,
|
Object? sqfliteFactory,
|
||||||
IdbFactory? idbFactory,
|
IdbFactory? idbFactory,
|
||||||
|
int version = 1,
|
||||||
}) async {
|
}) async {
|
||||||
idbFactory ??= window.indexedDB!;
|
idbFactory ??= window.indexedDB!;
|
||||||
final db = await idbFactory.open(name, version: 1,
|
final db = await idbFactory.open(name, version: version,
|
||||||
onUpgradeNeeded: (VersionChangeEvent event) {
|
onUpgradeNeeded: (VersionChangeEvent event) {
|
||||||
final db = event.target.result;
|
final db = event.target.result;
|
||||||
for (final name in boxNames) {
|
for (final name in boxNames) {
|
||||||
|
if (db.objectStoreNames.contains(name)) continue;
|
||||||
|
|
||||||
db.createObjectStore(name, autoIncrement: true);
|
db.createObjectStore(name, autoIncrement: true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,7 @@ class MatrixSdkDatabase extends DatabaseApi with DatabaseFileStorage {
|
||||||
sqfliteDatabase: database,
|
sqfliteDatabase: database,
|
||||||
sqfliteFactory: sqfliteFactory,
|
sqfliteFactory: sqfliteFactory,
|
||||||
idbFactory: idbFactory,
|
idbFactory: idbFactory,
|
||||||
|
version: version,
|
||||||
);
|
);
|
||||||
_clientBox = _collection.openBox<String>(
|
_clientBox = _collection.openBox<String>(
|
||||||
_clientBoxName,
|
_clientBoxName,
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class BoxCollection with ZoneTransactionMixin {
|
||||||
Object? sqfliteDatabase,
|
Object? sqfliteDatabase,
|
||||||
DatabaseFactory? sqfliteFactory,
|
DatabaseFactory? sqfliteFactory,
|
||||||
dynamic idbFactory,
|
dynamic idbFactory,
|
||||||
|
int version = 1,
|
||||||
}) async {
|
}) async {
|
||||||
if (sqfliteDatabase is! Database) {
|
if (sqfliteDatabase is! Database) {
|
||||||
throw ('You must provide a Database `sqfliteDatabase` for use on native.');
|
throw ('You must provide a Database `sqfliteDatabase` for use on native.');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue