The query ran without error, but the table was missing something. We needed a new column.
Adding a new column is more than schema change. It alters how your system stores, indexes, and retrieves data. The right approach keeps your database fast, consistent, and safe under load. The wrong one can lock tables, break queries, or cost hours of downtime.
First, choose the correct data type. Use the smallest type that fits the data to save memory and speed scans. Decide if the column should allow NULL values. Default values can help with backward compatibility, but be careful with non-null defaults on large tables; they can trigger full table rewrites.
Then, plan the migration path. For small tables, a direct ALTER TABLE ADD COLUMN works. On large, high-traffic tables, online schema change tools such as pt-online-schema-change or native database features like PostgreSQL’s ADD COLUMN with defaults in newer versions can avoid blocking writes. Always test the migration in staging with production-like data. Check how it interacts with application code, ORM layers, and external integrations.