Dark as of today (4/18/2020) does not support changing Datastore schemas. Therefore, you need to do a migration if you want to make schema changes.

Migrations in Dark are similar to migrations in traditional backend systems. The following steps outline a double-write strategy, which allows you to move data from Datastore A → B without taking down the service or losing data. If these are not concerns, you can use a REPL to move data from A → B and incrementally update callsites. However, you may want to use the following strategy regardless to have a less stressful migration 😬.

We'll use the simple example of adding an email field to a Users Datastore.

Double Write

Redirect reads

Cleanup

We want to get a state where the old Datastore has no more dependents.

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5f396dcd-7fa2-4065-bf37-cced9945e6b6/Untitled.png

Some migrations may be trickier, such as ones that migrate multiple Datastores at the same time. However, the same mental model applies of getting to a state where you have two usable up-to-date Datastores and then flipping the switch to read from the new Datastore.