Skip to content

Commit

Permalink
task(ardrive-web): increment schema to 10 PE-111 (#182)
Browse files Browse the repository at this point in the history
  • Loading branch information
javdhu authored Aug 2, 2021
1 parent 2b4ed9a commit 1a1fdaf
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions lib/models/database/database.dart
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
import 'package:moor/moor.dart';

import '../daos/daos.dart';
import 'unsupported.dart'
if (dart.library.html) 'web.dart'
if (dart.library.io) 'ffi.dart';

part 'database.g.dart';

@UseMoor(
include: {'../tables/all.moor'},
daos: [DriveDao, ProfileDao],
)
class Database extends _$Database {
Database([QueryExecutor e]) : super(e ?? openConnection());

@override
int get schemaVersion => 9;


@override
MigrationStrategy get migration => MigrationStrategy(
onCreate: (Migrator m) {
return m.createAll();
},
onUpgrade: (Migrator m, int from, int to) async {
print('schema changed from $from to $to ');
if (from >= 1 && from <= 8) {
// Reset the database.
for (final table in allTables) {
await m.deleteTable(table.actualTableName);
}

await m.createAll();
}
},
);
}
import 'package:moor/moor.dart';

import '../daos/daos.dart';
import 'unsupported.dart'
if (dart.library.html) 'web.dart'
if (dart.library.io) 'ffi.dart';

part 'database.g.dart';

@UseMoor(
include: {'../tables/all.moor'},
daos: [DriveDao, ProfileDao],
)
class Database extends _$Database {
Database([QueryExecutor e]) : super(e ?? openConnection());

@override
int get schemaVersion => 10;


@override
MigrationStrategy get migration => MigrationStrategy(
onCreate: (Migrator m) {
return m.createAll();
},
onUpgrade: (Migrator m, int from, int to) async {
print('schema changed from $from to $to ');
if (from >= 1 && from <= 9) {
// Reset the database.
for (final table in allTables) {
await m.deleteTable(table.actualTableName);
}

await m.createAll();
}
},
);
}

0 comments on commit 1a1fdaf

Please sign in to comment.