-
|
Hello, I am trying to switch my table from clientDefault to withDefault. What is the correct way to handle the migration ? What I have done
-BoolColumn get isMonthly => boolean().clientDefault(() => false)();
+BoolColumn get isMonthly => boolean().withDefault(const Constant(false))();
-DateTimeColumn get createdAt => dateTime().clientDefault(() => DateTime.now())();
+DateTimeColumn get createdAt => dateTime().withDefault(currentDateAndTime)();
from2To3: (m, schema) async {
// Switch clientDefault to withDefault
await m.alterTable(TableMigration(schema.transactions));
},Is this OK, can I go into production with this ? Why am I doing this ?During development I used clientDefault as mentioned in the doc
Recently, when I added a new column with clientDefault, the make-migrations tool warned me that the default value was missing. So I used withDefault for this new column. Final thoughtThe doc mentions the care required for the default value during migration, but I could not find any information on how to handle this properly.
Thanks a lot for your help !! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
|
That looks fine. Run the schema tests to confirm.
What was the warning? |
Beta Was this translation helpful? Give feedback.
-
|
What about it ?
Am I missing something ? Where in the doc can I find the proper way to handle this with |
Beta Was this translation helpful? Give feedback.
Looks good to me 👍