DEV Community

Cover image for Tick Tock migration pattern
Sibelius Seraphini for Woovi

Posted on

Tick Tock migration pattern

Tick Tock is when you do a migration in two steps to avoid breaking.

Tick

Image description

Imagine we have 2 different models/collections/tables to store transactions (TransactionModel) and refund transactions (TransactionRefundModel)
However, you figure it out that this 2 models should be the same collection.
What is the best approach to convert all TransactionRefundModel to TransactionModel?

The best approach is to start writing the refund transaction for both old and new model.
After this is done, you can compare if you are not losing information in this migration.
Then, you write a migration to migrate the old data to the new data.

This is the Tick part of the migration. You have 2 models working together.

Tock

Image description

The Tock part is modifying the code to read from the new data only.
After the reading new data is done and correct.
You can stop writing data to the old data.
Do not forget to cleanup the old data and code.


Woovi is a Startup that enables shoppers to pay as they like. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.

If you want to work with us, we are hiring!


Photo by Ethan M. on Unsplash

Top comments (0)