Adding a new column should be simple. In SQL, you run ALTER TABLE ADD COLUMN and move on. In many codebases, it is not that easy. Schema changes ripple through services, pipelines, APIs, and deployments. A new column is not just a field. It is an agreement between data and code.
The first step is to define the column in the database. For PostgreSQL:
ALTER TABLE users ADD COLUMN last_login TIMESTAMP;
If you work with large datasets, run it in a transaction or during a low-traffic window to avoid locking issues.
Next, update the ORM or data access layer. In frameworks like Django, add the field to the model and generate a migration. In TypeORM or Sequelize, update the entity definition and sync. Do not skip this. A database change without a matching model change will break queries in production.
Once the schema and model match, update all relevant read and write operations. If the column is nullable at first, you can roll it out without backfilling data. If it is required, populate it with defaults or computed values during migration. Always test both writes and reads in staging with production-like data.