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.

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.