Skip to content
Discussion options

You must be logged in to vote

The obvious solution of selecting everything to memory, pasting the non-null default, doing the schema migration, and then inserting the values seems overly complicated...

You can kind of optimize this (and use SQL tricks to avoid the "selecting everything to memory" part). You're already using the alterTable API which is the correct tool here, except that:

  1. alterTable already adds new columns as well, so you don't need an addColumn afterwards.
  2. You need to add a default value for existing rows in your database.

I think that something like this can work here:

stepByStep(
 from1To2: (m, schema) async {
   m.alterTable(TableMigration(schema.favorites, columnTransformer: {
     schema.favo…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by derdilla
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