Commit 43eb74f
committed
db test: Cover simple migrations without data programmatically
This saves us from writing the simple migration tests between schemas
without data in the future.
---
The tests are inspired by the test template generated from
`dart run drift_dev make-migrations`.
To reproduce the outputs, go through the following steps:
Modify `build.yaml` by specifying the location of the database. This
step is needed because `make-migrations` does not accept this through
command line arguments.
```
targets:
$default:
builders:
# ...
drift_dev:
options:
databases:
default: lib/model/database.dart
```
Then, run the following commands:
```
dart run drift_dev make-migrations
cp test/model/schemas/*.json drift_schemas/default/
dart run drift_dev make-migrations
```
The first `make-migrations` run generates the initial schema and test
files without looking at the versions we have in test/model/schemas.
Copying the schema files and running `make-migrations` will end up
creating `test/drift/default/migration_test.dart`, along with other
generated files.
See also:
https://drift.simonbinder.eu/Migrations/#usage
Signed-off-by: Zixuan James Li <[email protected]>1 parent a73e7c9 commit 43eb74f
1 file changed
+24
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
106 | 125 | | |
107 | 126 | | |
108 | 127 | | |
| |||
0 commit comments