Replies: 2 comments
-
This recommendation was updated recently to account for this. However for old users, we should add this to the docs/command line output/ warn the user if the constructor doesn't match.
Good point. At example of actualy migrations should be on this page. Also, testing should be on this page too!
These were writen waay before make-migrations existed. Agree.
@simolus3 how did we miss this? What are users to do?
Good point. These should be added to This is clearly an issue. Gonna try to make time for it. |
Beta Was this translation helpful? Give feedback.
-
I think When reading the docs I often felt like reading "This is what you can do ...". But as a noob in migrations I'm rather lost between the different examples - I rather wanted to know "what I should do" when using the step-by-step migration. A dedicated stepwise dot-point list from start (initial schema generation) to end (testing) for step-by-step migrations would be highly beneficial. as for the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I've implemented my first migration using the step-by-step approach but I encountered several obstacles.
This is a summarization of my experience and some recommendations how to improve the documentation to make it easier for everyone.
First of all, I followed the Getting Started document closely.
This is great!!! But first wrong assumption: the all-in-one command does everything for me. 🔥
I followed the steps:
dart run drift_dev make-migrations
) ✅schemaVersion
in your database class" ✅dart run drift_dev make-migrations
) ✅Huh? Write my migrations incrementally? How? 🤔
There is:
make-migrations
command:It turns out that the example in the
make-migrations
command would is best to go ahead, but I got lost in the examples given in the documentation before I figured this out. 🙁👉 A first example for the step-by-step migration should actually be shown on the Getting Started page instead of other pages that cover much more ground.
However, there are still two issues:
import 'database.steps.dart';
is missing@override
annotation is missing for the getterAnd another issue: I had to change
AppDatabase() : super(_openConnection());
to
AppDatabase([QueryExecutor? e]) : super(e ?? _openConnection());
Luckily, this was mentioned in the output of
make-migrations
command.Finally, the
make-migrations
command recommended to run the generated tests withflutter test test/drift/app_database/migration_test.dart
.Again, the documentation does not cover this in the getting started section.
And last but not least...
m.dropColumn()
in a type-safe way, because only the new schema is passed as parameter.TL;TR
The Getting Started documentation is great but not clear enough on all steps for doing your first step-by-step migration.
Other people also had problems with doing this start-to-end, e.g. here and here.
I'd recommend that the Getting Started page is improved such that each step for doing the first step-by-step migration is clearly listed, e.g.
dart run drift_dev make-migrations
)schemaVersion
in your database class"dart run drift_dev make-migrations
) and follow advices given in the output.flutter test test/drift/app_database/migration_test.dart
.Beta Was this translation helpful? Give feedback.
All reactions