DEV Community

Discussion on: Getting Into Microservices? Don't Build a Spaghetti Monster.

Collapse
 
jdforsythe profile image
Jeremy Forsythe • Edited

Can you elaborate on running migrations in the CI/CD pipeline? Do you have migrations as a part of the microservice owning the database and run them on successful build? What happens on failure? Obviously the app has to be forward compatible to handle a migration running before a deploy, so how do you handle breaking changes to the schema?

We currently run migrations on deploy with a strict set of rules for forward and backward compatibility and require two migrations for breaking changes (deprecation and then removal) which works okay and ensures consistency, but I'd like to hear how you do this and see if it is any simpler.

Collapse
 
markoa profile image
Marko Anastasov

Thanks for the question. I haven’t seen a simpler way, and the approach works for both monoliths and microservices.

  1. Write and deploy code that works with both old and new schema.
  2. Write and deploy migrations.
  3. Remove code that works with old version.