Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ship database updates?

I have a Java application (generic) that uses a database via hibernate. I ship it via jar to clients. Which is the best way to ship database updates (schema and data) to clients? Consider that clients can have different version of my application, and the update must be automatic, without user support. And if the application is written with grails?

like image 333
tapioco123 Avatar asked May 10 '26 20:05

tapioco123


1 Answers

You can do this by keeping track of the current schema version (i.e. revision number) and then having a patch file to bring the schema up to the next version. You can keep applying patches incrementally until you reach the new prod/update version.

E.g. Say client is at revision 5. You have since shipped out revision 10 and 12 but he only updates to the latest one -- 15.

You can do:

foreach rev in [clientRev ... currentRev]:
   apply rev.patch

So you'll be applying the patch to bring up to rev 10; then another one to bring it to rev 12; then another one to bring it to rev 15;

If a different client is at rev 12 already they will only need to apply the last patch.

like image 121
naumcho Avatar answered May 13 '26 10:05

naumcho



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!