BM: Baca dalam Bahasa Melayu
World C3: Release & Deploy
Database changes without downtime
You will learn: how to change a database in safe steps while old and new code both run.
Checked with GitHub Actions 2026-10 on 31 Oct 2026
The problem
You renamed the column phone to mobile. Version 2 is happy. But version 1 copies still run during the rollout. Plain words: old code asks for a column that is gone.
Watch
During a rolling or canary deploy, who reads and writes the database?
Pick one answer.
Watch
The fix is expand and contract: Change a database in safe steps: add the new shelf, move the stock, then remove the old shelf. Old and new code keep working.. Change the pantry in safe steps. Add the new shelf, move the stock, then remove the old one. Put the steps in order.
First step at the top. Put these in order. Use the arrows, or drag.
- Contract: drop the old phone column
- Expand: add the new column, mobile
- Deploy code that writes to both columns
- Migrate: copy old numbers into mobile
- Deploy code that uses only mobile
Try it
Which changes are safe in one deploy? Sort them.
Drag a card into a box. Or tap the card, then tap the box.
Predict
You are at step 2: both columns exist. Version 2 has a bug. Can you roll back to version 1?
Pick one answer.
Check
Step 1 for real, on PostgreSQL 18. ADD COLUMN adds an empty shelf. Old code still reads phone. New code can start writing mobile.
You did it!
You can now change a database without closing the shop.
Go deeper (optional)
Run each migration as its own step, before the code that needs it. Some changes lock a big table while they run. Read your database’s docs first. And remember: a rollback swaps code, not data. Cloudflare’s rollback leaves databases and other bindings as they are.
Real rep (optional): try these steps on a throwaway database: docker run --rm -e POSTGRES_PASSWORD=test postgres:18-alpine.
Bahasa Melayu
Anda tukar nama lajur phone kepada mobile. Versi 2 okey. Tapi salinan versi 1 masih berjalan semasa rollout. Maksudnya: kod lama minta lajur yang dah tiada.
Semasa deploy rolling atau canary, siapa yang baca dan tulis pangkalan data?
Penyelesaiannya ialah expand dan contract. Ubah stor langkah demi langkah. Tambah rak baharu, pindah stok, kemudian buang rak lama. Susun langkahnya.
Perubahan mana yang selamat dalam satu deploy? Susun.
Anda di langkah 2: kedua-dua lajur wujud. Versi 2 ada bug. Boleh anda rollback ke versi 1?
Langkah 1 betul-betul, pada PostgreSQL 18. ADD COLUMN tambah rak kosong. Kod lama masih baca phone. Kod baharu boleh mula tulis mobile.
Kini anda boleh ubah pangkalan data tanpa tutup kedai.
You finished this before. Practice is always welcome!
Official docs: PostgreSQL 18: ALTER TABLE · Parallel change (expand and contract) · Cloudflare: rollbacks leave data as it is
You've learned for 25 minutes. A short break helps your brain.
Sprint done! Great focus. Stretch for a minute?