Adding a new column to a production database sounds trivial until latency spikes, locks pile up, or the migration stalls. Execution matters. Schema changes in live systems should be fast, safe, and reversible.
A new column starts with definition. In SQL, you use ALTER TABLE. The exact syntax depends on your database:
ALTER TABLE users
ADD COLUMN profile_image_url TEXT;
This command updates the schema, but the impact depends on the engine. PostgreSQL can often add a nullable column instantly. MySQL might need to rewrite the table for certain data types or defaults.
If you need the column to be non-nullable from day one, avoid writing defaults that trigger a full table rewrite on large datasets. Instead, add it nullable, backfill data in small batches, then enforce constraints. Always index only after data is populated to prevent expensive index builds during the backfill.