Skip to content
Discussion options

You must be logged in to vote

Inserting a bogus value into ProductCategories that is later replaced with real data could be a good approach when adding the new column. Other approaches might be to make the column nullable, but only use NULL for old, existing rows.

If you want to go with this approach but add type-safety, you're correct that using the current companions is dangerous since they could be altered in subsequent schema versions. You can run something like dart run drift_dev schema generate drift_schemas/default lib/src/schema_versions --data-classes --companions to generate all schemas with companions for that specific schema version. Doing this for all schema versions can generate quite a bit of code thoug…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Romain-Guillot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants