-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into new-schema-docs
- Loading branch information
Showing
67 changed files
with
1,407 additions
and
683 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
docs/lib/snippets/migrations/runtime_verification_web.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import 'package:drift/drift.dart'; | ||
|
||
// #docregion web | ||
// import the migrations tooling | ||
import 'package:drift_dev/api/migrations_web.dart'; | ||
import 'package:sqlite3/wasm.dart'; | ||
// #enddocregion web | ||
|
||
const kDebugMode = true; | ||
|
||
abstract class _$MyDatabase extends GeneratedDatabase { | ||
_$MyDatabase(super.executor); | ||
} | ||
|
||
// #docregion web | ||
|
||
class MyDatabase extends _$MyDatabase { | ||
// #enddocregion web | ||
MyDatabase(super.executor); | ||
|
||
@override | ||
Iterable<TableInfo<Table, dynamic>> get allTables => | ||
throw UnimplementedError(); | ||
|
||
@override | ||
int get schemaVersion => throw UnimplementedError(); | ||
|
||
// #docregion web | ||
@override | ||
MigrationStrategy get migration => MigrationStrategy( | ||
onCreate: (m) async {/* ... */}, | ||
onUpgrade: (m, from, to) async {/* your existing migration logic */}, | ||
beforeOpen: (details) async { | ||
// your existing beforeOpen callback, enable foreign keys, etc. | ||
|
||
// This check pulls in a fair amount of code that's not needed | ||
// anywhere else, so we recommend only doing it in debug builds. | ||
if (kDebugMode) { | ||
// The web schema verifier needs a sqlite3 instance to open another | ||
// version of your database so that the two can be compared. | ||
final sqlite3 = await WasmSqlite3.loadFromUrl(Uri.parse('/')); | ||
sqlite3.registerVirtualFileSystem(InMemoryFileSystem(), | ||
makeDefault: true); | ||
await validateDatabaseSchema(sqlite3: sqlite3); | ||
} | ||
}, | ||
); | ||
} | ||
// #enddocregion web |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/lib/snippets/migrations/tests/verify_data_integrity_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.