The query ran fast. The schema was wrong. The logs told you the truth: you need a new column.
Adding a new column sounds simple but can break systems if done without care. The goal is zero downtime and no data loss. Start by defining the new column in your migration tool. Use a clear, immutable name. Avoid overloaded terms. Choose the smallest data type that fits the long-term use case.
In production systems, adding a column to a large table can lock writes. Use an online schema change method if your database supports it. For MySQL, tools like gh-ost or pt-online-schema-change help avoid blocking. In PostgreSQL, adding a nullable column without a default is fast because metadata changes, not the actual rows. But adding a column with a default value forces a table rewrite—plan your migration steps to avoid that.
Test the new column in a staging environment with realistic data volume. Observe query plans before and after. Ensure indexes are added only after verifying query patterns. Avoid premature indexing—each index adds write overhead.