Git Product home page Git Product logo

expand-contract-db-pattern's Introduction

Expand-Contract Pattern applied in Rolling Upgrade Deployment

Technologies used

  • Java 11
  • Maven
  • Quarkus framework
  • Docker
  • Kubernetes
  • Jib
  • HTML/CSS/JS
  • Weave Scope visualisation & monitoring tool
  • PostgreSQL
  • Flyway

Techniques used

Architecture

Application Architecture

Packaging and running the example in a kubernetes cluster

  1. Start minikube with the following addons:
minikube start --addons registry, ingress
  1. Forward the image registry port:
kubectl port-forward --namespace kube-system registry-<id> 5000:5000
  1. Run the deployment script:
./minikube-deploy.sh
  1. Get ngnix IP from ADDRESS column using:
kubectl get ingress -n custom
  1. Map customer.domain to the IP provided by step above to etc/hosts

  2. Access the application on http://customer.domain

Expand/Contract demo explanation

Beside master branch you have 3 additional branches that represent 3 backward compatible database versions.

The problem:

You need to split name column into two separate columns, first name and last name and to maintain backward compatibility with the previous version.

Solution:

Migration version Branch State What happens to the database?
V1.0 demo/v1_starting_state Starting Create a customer table that contains an ID and a name
V2.0 demo/v2_expand_state Expand Append first_name and last_name column. Bidirectional synchronization using triggers between name and (first_name, last_name)
V3.0 demo/v3_contract_state Contract After all clients migrated to V2.0, in this state you can remove the old column name and also the synchronization triggers.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.