The migration finished at midnight, but the schema wasn’t done evolving. A new column was needed—fast. Not next sprint. Now.
Adding a new column sounds simple, but precision matters. The wrong approach can lock tables, slow queries, or break production. The right approach makes the change invisible to users, while keeping your data safe and the application online.
Start with clarity. Define the column name, type, default value, and constraints. Avoid vague names—schema is forever. If this new column interacts with existing indexes, plan how they will be updated.
For live systems, use migrations that run without full table locks. In PostgreSQL, ADD COLUMN without a default value is instant. Apply defaults in a separate statement to avoid rewriting the table. In MySQL, consider ALGORITHM=INPLACE migrations. Test these steps in a staging database with realistic data size—performance in development means nothing at scale.