The query returned, and the log showed the same problem: no column for the new data.
Adding a new column seems simple. In production systems, it is not. Schema changes can break queries, slow deployments, and increase downtime risk. The right approach depends on the size of your tables, the database engine, and your tolerance for blocking writes.
Start with an explicit migration plan. In PostgreSQL, ALTER TABLE ADD COLUMN is fast for nullable columns without a default. It only updates metadata. But setting a non-null default rewrites the whole table and can lock it. For MySQL, the process can be slower, especially on large datasets. Use ALTER TABLE with caution, and test performance on a snapshot before running in production.
Zero-downtime deployment often requires a phased rollout. First, add the new column as nullable. Then, backfill in batches to avoid overwhelming the CPU or I/O. Finally, add constraints or indexes once the data is in place. Tools like pt-online-schema-change or gh-ost can help with MySQL migrations. In PostgreSQL, use background workers, application-layer updates, or logical replication to handle the load.