Data migration script upon deploy

Is there any mechanism for setting values into newly created fields on models upon deploying or pushing to a new environment? The Gadget AI agent recommended creating a new global action for this - just wasn't sure if there was anything baked in.
9 Replies
Smelvin
Smelvin•2mo ago
There are default values for model fields but I assume that wont fit your use case. There isnt any build in Gadget functions for this otherwise
kalenjordan
kalenjordanOP•2w ago
gotcha @[Gadget] Antoine just wanted to double check - there's no concept of data migrations in gadget....?
Chocci_Milk
Chocci_Milk•2w ago
No, there is no such thing as a built in data migration in Gadget at the moment
stevied9460
stevied9460•2w ago
This is a simple problem for Gadget but if they enable this via say CSV import will they get a gazillion support requests from people ignoring the database relationships and structures. Or will they end up with convoluted code for edge cases. I wrote my own and hid it in an admin route. Allows me to import any CSV as long as the headers exactly match the model and strips out any records with null values for required fields. Ai did nearly all the work. Only 8 models and <100 records per model. 4 hours work roughly inculding the UI.
kalenjordan
kalenjordanOP•2w ago
Went ahead and just built out a little migrations cli that I'm tying into my github deploy workflows.
Simon
Simon•2w ago
neat! What's your core use case? backfilling default values?
kalenjordan
kalenjordanOP•2w ago
yeah pretty much also just like adding a shop field to a model where it was missing previously and then populating it kinda thing
Simon
Simon•2w ago
Right. I typically create a simple global action in gadget and just run it right after deploy. But I don't have any advanced github deploy workflow either 😀

Did you find this page helpful?