Data Modeling and Migrations
Bad schema decisions are expensive to fix later. Plan for change from the start.
Data modeling essentials
- Normalize where needed, denormalize where useful
- Define clear ownership of data entities
- Use indexes intentionally
- Track constraints and invariants in schema
Migration safety
- Make migrations forward-compatible
- Avoid long locks on large tables
- Backfill data in batches
- Validate before and after migration
- Keep rollback strategy ready