Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Art of Migration and Versioning

The Art of Migration and Versioning

Avatar for Muhammad Mufid Afif

Muhammad Mufid Afif

July 15, 2017
Tweet

More Decks by Muhammad Mufid Afif

Other Decks in Programming

Transcript

  1. It Can Break The App! The art of Migration and

    Versioning Muhammad Mufid Afif https://mufid.github.io July 15th, 2017 LightningTalk @ GeekCamp ID 2017 SCTV Tower
  2. 1

  3. Why we need migration and versioning? Version 1 Version 2

    Table: Books Title: String BookType: Integer Table: Books Title: String BookType: String
  4. Why we need migration and versioning? Version 1 Version 2

    Table: Books Title: String BookType: Integer Table: Books Title: String BookType: String Not backward compatible Not forward compatible
  5. Why we need migration and versioning? Version 1 Version 2

    Table: Books Title: String BookType: Integer Table: Books Title: String BookType: Integer BookTypeName: String Better!
  6. Migrating DB • Always make sure have backup! • Check:

    is it blocking operation? Is downtime allowed? • Check: have you run old version with new db, and new version with old db? • Everything checked? Deploy!
  7. DB Migration: Does it requires downtime? Operation Blocking operation? Add

    column without DEFAULT No Add column with DEFAULT Yes Create new table No Add new index use CONCURRENTLY
  8. It is always safe to add thing But please do

    deletion and data changing in different version!
  9. 2

  10. Game: Maintenance Period & version matching Some games doesn't allow

    multiple versions running and doesn't keep at 100% availability
  11. 3

  12. Protocol, Compared Protocol Definition File Definition File is Remotely Acessible?

    SOAP Yes Yes JSON/REST via Swagger or whatever via Docs GraphQL Yes via Docs GRPC / Protobuf Yes via proto File
  13. Perhaps, definition can be accessed by client is a good

    thing. They can check whether they're using actual version, or they must upgrade theirself before calling APIs.
  14. Protocol, Compared Protocol Protocol Base Protocol Syntax SOAP HTTP XML

    JSON/REST HTTP JSON GraphQL HTTP GraphQL GRPC / Protobuf Strictly H2 Protobuf
  15. But still, all of them failed to address our problem!

    Protocol Allow field change? SOAP No JSON/REST No GraphQL No GRPC / Protobuf No
  16. Versioning API • Soft deprecate old method / field: announce

    warnings • Hard deprecate old method / field: throw error • Delete the method / field
  17. Conclusion • Target your audience. Who will use your app?

    Is it mission-critical things? • Target the change. Should previous data preserved? • Target the availability. Is 100% availability is a must? • At any changes, either in migration or versioning, it is always safe to add things, but be careful when changing / deleting things.