The migration runs without errors. Now you need a new column.
Adding a new column should be fast, safe, and predictable. Yet production systems carry risk. Schema changes lock tables, trigger indexing costs, and may cascade into deployment delays. The right approach depends on your database, traffic patterns, and operational tolerance.
In SQL, the basic syntax is simple:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
This works in PostgreSQL, MySQL, and most relational databases. But simplicity in syntax hides complexity in execution. On large tables, a new column can cause downtime if the database must rewrite the entire table.
To avoid this, use non-blocking migrations when supported. In PostgreSQL, adding a nullable column with a default of NULL is instant because it only updates metadata. Adding a column with a non-null default can rewrite data. To keep deployments fast: