Say, you want to change schema A to schema B. Here’s a reference to all the steps you need.

(here’s someone elaborated it: https://kiranrao.ca/2022/05/04/zero-downtime-migrations.html)

  1. Create schema B.

  2. Write a script to copy data from schema A to schema B. (You will need it later).
    Script must be idempotent to run multiple times.

  3. Copy the data.

  4. Change main code to write to schema B.

  5. Copy the data again (in case between steps 3. and 4. there were some missing writes).

  6. Change main code to read from schema B, but don’t use it yet.
    Just compare with what was read from schema A, and monitor the differences.

  7. Wait for some time to make sure all reads are fine.

  8. Switch to using data from schema B (but reading schema A and monitor differences).

  9. Wait for M days to make sure users are happy as well, not just your monitoring.

  10. Turn off schema A.