API Versioning with Document DB

Context

You have a document database, let's say DynamoDB. It has about 10m of person's name data, for example:

 The data is accessible through a highly scalable API and being consumed by 100+ other services. Over the course of few years there are some significant changes that require several iterations of the data and API, but all versions have to be maintained due to various legacy clients. The iterations are summarised as follow:

V2: Suffixes are now mandatory

V3: Title is now forbidden

V4: Givenname to change to Firstname

V5: Tony Stark Jr is now the supreme leader of earth, all Stark lastname must be capitalised

Forces

  • You only have one Document DB
  • All versions must be maintained

Solution

V2: Suffixes are now mandatory

Adding a new field is quite straight forward, we simply add to the Document DB
V1: leave it unchanged or update it to make sure that it does not return Suffix


V3: Title is now forbidden

Removing a field is trickier, since we have to maintain backward compatibility, we will need to handle it via API
V1: leave it unchanged or update it to make sure that it does not return Suffix
V2: leave it unchanged
V3: return the document without Title (unfortunately this will confuse future developers)



V4: Givenname to change to Firstname

Updating a field is even more complex, but despite maintaining backward compatibility, it is better to maintain the currency of the DB. Maintaining the currency of the DB is important because when we don't know when we can decomission the old versions, it is better to update the DB now, than later when the version is decommisioned

V1: change so that it returns Givenname and does not return Suffix
V2: change so that it returns Givenname
V3: change so that it returns Givenname and does not return Title (unfortunately this will confuse future developers)


V5: Tony Stark Jr is now the supreme leader of earth, all Stark lastname must be capitalised

Updating value is probably rare and done on case by case basis but whenever logical, it is generally advisable to maintain the currency of the database. In this scenario, this is best achieved with a versioned new field

V1: change so that it returns Givenname and does not return Suffix
V2: change so that it returns Givenname
V3: change so that it returns Givenname and does not return Title (unfortunately this will confuse future developers)
V4: no change or update it to make sure it does not return LastnameV5
V5: return LastnameV5 in place of Lastname





Comments

Popular posts from this blog

Spring Boot 2: Parallelism with Spring WebFlux

Spring Boot Reactive API