Adding a new column sounds simple. In code, one command can create it. In production, mistakes can stall releases, break scripts, or lock tables. Performance drops. Migrations run long. The fix is knowing the right way to add a column across environments without risking downtime.
In SQL, ALTER TABLE is the standard method. For small tables, you can run:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
For large tables, this can block reads and writes. Use ALTER TABLE ... ADD COLUMN with DEFAULT NULL first, then backfill values in batches. Avoid setting defaults that require a full table rewrite during creation. In PostgreSQL, adding a nullable column is usually instant. In MySQL, it depends on your storage engine and version.
Schema changes should be part of version-controlled migrations. This keeps database state consistent across dev, staging, and production. Tools like Liquibase, Flyway, or simple migration scripts help manage changes. Always test migrations on a production-sized dataset clone before rolling out.