Adding a new column should be direct, fast, and safe. Whether your database is PostgreSQL, MySQL, or a modern cloud-native system, the steps are the same: define, alter, migrate, and verify. The challenge is avoiding locks, downtime, and silent bugs.
First, design the schema change. Decide on the column name and data type. Keep names short and consistent with existing conventions. Set nullability based on how the column will be populated. If defaults are required, be careful—large tables with default values can trigger full rewrites of the data, increasing migration time.
Second, alter the table. In SQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
In high-volume systems, consider adding columns without defaults and backfilling later to avoid locking. Tools like gh-ost or pg_online_schema_change can run online migrations.