Adding a new column to a database can be simple or it can break production if you handle it wrong. Schema changes must be planned, tested, and deployed with precision. Whether you use PostgreSQL, MySQL, or a cloud-native datastore, the principle stays the same: create minimal risk while keeping performance stable.
Start by defining the exact column name and type. Use names that match your data model and make sense across services. In SQL, the basic command is direct:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
For large tables, avoid locking writes during migrations. Tools like pg_online_schema_change or MySQL’s gh-ost let you add a new column without heavy downtime. If you run microservices, ensure migrations and application code changes are synchronized. Deploy in steps—first add the column, then deploy code that writes to it, then read from it once data exists.