Lesson 13 of 14
Versioning Documents without Migrations - 013
Schema marindi, ippudu 1 Million documents update cheyyala? Avasaram ledu. Versioning Schema pattern vadandi.
Core Explanation: Prati document lo schema_version field pettandi. App code lo logic rayandi: Version 1 vasthe ela handle cheyyali, Version 2 vasthe ela. Read chesinappudu, avasaram aithe appude migrate cheyyandi (Justin-Time Migration) or Write chesetappudu upgrade cheyyandi.
Wrong Practice: Downtime migration script running on Sunday night.
// Updating 10M records at once... DB Locks... CPU Spike... Alerts!
Best Practice: Schema Versioning Pattern.
// Doc
{
"schema_v": 2,
"name": "Pavan",
"contact": { "phone": "..." } // v2 structure
}
App Logic: if (doc.schema_v == 1) { return convertV1toV2(doc); }
Closing Insight: "Changes ni Lazy ga apply cheyyandi. Batch migrations production killers."