When you add a new column to a database table, you rewrite the contract between the table and every process that touches it. Schema migrations must be precise. Downtime must be avoided. Data integrity must be preserved.
The first step is defining the column: name, datatype, default values, nullability. Choose types that match your workload and indexing strategy. A poorly chosen type can fragment memory or slow queries for years.
Next, plan the migration path. For live systems, run zero-downtime migrations. Break the change into steps:
- Add the new column without constraints.
- Backfill data in controlled batches.
- Apply constraints and indexes only after validation.
Concurrent writes during migration require transactional safety. Locking large tables can freeze an application. Use online schema change tools or write your own migration scripts with retry logic.