Nozbe / WatermelonDB

🍉 Reactive & asynchronous database for powerful React and React Native apps ⚡️
https://watermelondb.dev
MIT License
10.49k stars 589 forks source link

Rollback on production app #1815

Closed LukasMod closed 2 months ago

LukasMod commented 2 months ago

Hey, does anyone have an idea how to properly do a rollback of an application on prod? An update changes the schema, then it turns out we need to do a rollback. How to do it without clearing the database?

From docs: There's no automatic "rollback" feature in Watermelon. But maybe someone has a way to do it. I was thinking of synchronizing important data from the backend in onSetUpError().

diegolmello commented 2 months ago

Useful workaround: If data is not corrupted and you can keep the migration, make a new version containing the migration, but removing whatever else you need to remove. The rollback will require a new version on the stores anyway. I did it a few years ago and it worked nicely.

LukasMod commented 2 months ago

@diegolmello thanks so much!

I created a rollback version with an older version of the application, but with a new build number. I kept migrations.ts and schema.ts as you said and data was preserved. I think this workaround is good enough for me to handle some edge case in bigger app realeses.