Adding a new column should be simple. Often it is not. Databases carry history. Schema changes ripple through services, APIs, and code paths. A careless migration can stall deployments, lock tables, or trigger cascading failures. The cost of getting it wrong is high.
A new column starts with purpose. Define the name, type, and constraints. Decide if it can be null, if it needs a default, if it should be indexed. Aim for clarity. Use consistent naming patterns and make the column’s role obvious. Avoid overloading it with multiple meanings.
For relational databases, plan the migration. Large tables may require an online schema change to avoid downtime. In PostgreSQL, adding a column with a default value prior to version 11 rewrites the table. On MySQL, indexing the new column can block writes. Use tools like pt-online-schema-change or native online DDL features to keep systems responsive.
Update the application code before the column goes live. Feature flag reads and writes to ensure backward compatibility. Run dual writes during the transition if other services depend on the data. Keep both old and new paths in sync until the cutover is complete.