{
  "id": 21735450,
  "title": "Renaming a Database Column Without Downtime",
  "url": "https://urgent.news/2026/11/25/renaming-a-database-column-without-downtime",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-25T04:25:34.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/sanjay_singh_1/renaming-a-database-column-without-downtime-3366"
  },
  "original_language": "en",
  "account": "This guide outlines a method for renaming a database column on a live PostgreSQL database without causing any downtime. The key steps are:\n\n1. Add the new column (display_name) to the table with a nullable type. This is done during a migration, without modifying existing data.\n\n2. Dual-write all writes to both the old fullname column and the new display_name column. This ensures data consistency during the transition period.\n\n3. Backfill the display_name column by updating rows where display_name is null, using the existing fullname values. This is done in batches to avoid locking the entire table for too long.\n\n4. Verify that every row now has a value in the display_name column, matching the original fullname values. This is done by running a verification query.\n\n5. Switch reads to use the new display_name column. The old app code continues to write to both columns.\n\n6. Stop writing to the old fullname column and only write to display_name. The old column can be dropped in a separate migration step.\n\n7. Drop the old fullname column. This step is only performed after all other steps have been completed successfully. It requires a lock timeout to prevent blocking other queries.\n\nThe guide emphasizes the importance of testing each step carefully, rolling back if necessary, and ensuring that background jobs, cron scripts and other processes are updated to work with the new column name. By incrementally implementing the rename, it's possible to avoid long periods of downtime and maintain data integrity during the transition.",
  "summary": "My earlier posts kept saying \"expand and contract\" without ever showing it end to end. This one does. I'll rename users.fullname to users.display_name on a live PostgreSQL database, one safe step at a time. The sequence works on any database, but the SQL and locking details below are PostgreSQL. TL;DR: never rename in one step. Add the new column, dual-write, backfill in batches, verify, switch…",
  "key_points": [
    "Add new column displayname with nullable type during migration",
    "Dual-write old fullname and new displayname columns for data consistency",
    "Drop old fullname column after verifying displayname consistency"
  ],
  "editors_take": "Implementing a multi-stage migration process allows developers to evolve database schemas while maintaining continuous service availability and protecting data integrity through incremental updates and dual-writing strategies.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}