Adding a new column can be simple or destructive. Done right, it expands your schema without downtime. Done wrong, it locks queries, blocks writes, or corrupts data. The key is to treat migrations as code.
First, name your new column with purpose. Use lowercase, underscores, and clarity. Avoid generic names like data or info. Schema clarity compounds over time.
Second, choose the correct type. For numeric values, define precision. For strings, set explicit lengths. For timestamps, decide between TIMESTAMP and TIMESTAMPTZ. Match the column type to how the data will be queried and stored.
Third, set sensible defaults and nullability. Adding a column with NOT NULL but no default will fail if rows exist. Plan the migration with safe defaults, then backfill if needed.
Fourth, if you work at scale, make the change online. Tools like gh-ost (MySQL) or pg_online_schema_change (PostgreSQL) avoid locking the table. These allow zero-downtime column additions in production.