Improve docs on post-migration callbacks, typo

This commit is contained in:
Simon Binder 2020-03-03 22:25:09 +01:00
parent 6c6b198943
commit 51ba217484
No known key found for this signature in database
GPG Key ID: 7891917E4147B8C0
2 changed files with 8 additions and 4 deletions

View File

@ -48,8 +48,12 @@ can be used together with [`issueCustomQuery`](https://pub.dev/documentation/moo
to run the statements.
## Post-migration callbacks
Starting from moor 1.5, you can use the `beforeOpen` parameter in the `MigrationStrategy` which will be called after
migrations, but after any other queries are run. You could use it to populate data after the database has been created:
The `beforeOpen` parameter in `MigrationStrategy` can be used to populate data after the database has been created.
It runs after migrations, but before any other query. Note that it will be called whenever the database is opened,
regardless of whether a migration actually ran or not. You can use `details.hadUpgrade` or `details.wasCreated` to
check whether migrations were necessary:
```dart
beforeOpen: (details) async {
if (details.wasCreated) {

View File

@ -9,7 +9,7 @@
## 2.0.0
See the changelog of [moor](https://pub.dev/packages/moor#-changelog-tab-) for details,
or check out an overview of new features [here](https://moor.simonbinder.eu/v2])
or check out an overview of new features [here](https://moor.simonbinder.eu/v2)
## 1.7.0
- Support custom columns via type converters. See the [docs](https://moor.simonbinder.eu/type_converters)
@ -125,4 +125,4 @@ be just `_YourNameHere` (without the dollar sign)
- Transactions
## 1.0.0
- Initial release
- Initial release