Adding a new column to a live database is simple in theory. In practice, it can break queries, lock tables, and stall deployments if done carelessly. The goal is to make the change fast, safe, and reversible. Whether using PostgreSQL, MySQL, or another relational database, the principles are the same: plan, run, verify.
First, define the column with precision. Pick the right data type, constraints, and defaults. Avoid nulls unless truly needed. Assign default values for backward compatibility. Name it in line with existing conventions to keep maintenance clean.
Second, apply the change using a migration system. Keep the ALTER TABLE statement in version control. For large datasets, use techniques that minimize lock time. Tools like pt-online-schema-change or native database features can help. Test on a staging environment with production-like data. Time the migration to measure its impact.