Commit 61366a2
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. For the test that upgrade the schema with
data, with the helper, while it ended up having more lines than the
original, the test becomes more structured this way.
---
The tests are adapted from 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 61366a2
1 file changed
+23
-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 | + | |
106 | 124 | | |
107 | 125 | | |
108 | 126 | | |
| |||
0 commit comments