Adding a new column is one of the most common database changes, yet it can break production if done carelessly. Whether you use PostgreSQL, MySQL, or SQLite, the approach must be precise to avoid downtime, locked writes, or corrupted data.
First, define the column attributes. Set the correct data type, nullability, and default values before touching the database. For large datasets, avoid operations that force the table to rewrite completely. In PostgreSQL, using ALTER TABLE ... ADD COLUMN with a default value can lock the table; instead, add the column without defaults, then backfill asynchronously.
Second, consider migrations. If you deploy continuously, use schema versions with clear upgrade paths. Avoid destructive changes; make them additive. Add the new column, deploy code that can read and write both the old and new schema, then remove old logic only after the migration has fully completed.