The table was wrong. You knew it the moment the query finished. The data was good, but the schema was missing something vital: a new column.
Adding a new column is one of the most common schema changes in modern systems. It can be simple, or it can break everything if done without care. The way you add it depends on the database engine, the table size, and whether you can afford downtime.
For relational databases like PostgreSQL or MySQL, ALTER TABLE is the default tool. On a small table, adding a new column with a default value happens fast. On a large table, that same change can lock writes for minutes or hours. Some engines support metadata-only operations for nullable columns or default values without backfilling. Knowing these details lets you ship changes without killing performance.
In distributed databases, every new column must replicate to all nodes. That means schema migrations can cause cluster-wide contention. Tools like pt-online-schema-change, gh-ost, or native partition-aware DDL can help, but they add operational complexity. Always test migrations in a staging environment that mirrors production load.