Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Renaming a Database Column Without Downtime

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…

This guide outlines a method for renaming a database column on a live PostgreSQL database without causing any downtime. The key steps are:

1. Add the new column (display_name) to the table with a nullable type. This is done during a migration, without modifying existing data.

2. Dual-write all writes to both the old fullname column and the new display_name column. This ensures data consistency during the transition period.

3. 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.

4. 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.

5. Switch reads to use the new display_name column. The old app code continues to write to both columns.

6. Stop writing to the old fullname column and only write to display_name. The old column can be dropped in a separate migration step.

7. 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.

The 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.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Amazon product search as JSON: prices, ratings and sponsored flags in 20 lines of Python

Amazon's official Product Advertising API requires an approved Associates account and ongoing qualifying sales. If you are building a small price monitor, competitor tracker, or catalog lookup tool…

  • Amazon Product Advertising API provides structured JSON search results
  • POST request to /amazon/search endpoint with search term and API key
  • Retrieves product details like prices, ratings, and sponsored flags

How to Verify a Hosting Provider Before You Buy

Originally published on my blog — read it there with the full context, code and updates . Every hosting provider's homepage is a list of promises: "in business since 2005" , "guaranteed uptime"…

  • Examine domain age vs provider's claimed "since" date
  • Scrutinize Acceptable Use Policy (AUP) for prohibited activities
  • Conduct reputation check using third-party sources like Trustpilot

We tested agile "85% delivery dates" on 53 public Jira projects. Here is what held up.

Written by MV2 of Munim, Inc. The study, the code and this post were made with AI agents working in my name; no human expert has reviewed the study yet. Everything below is reproducible from the repo.

  • Agile "85% delivery dates" predictions often overly optimistic
  • Ship Odds tool recalibrates predictions based on historical data
  • Recalibration improves accuracy for some teams but not uniformly

How to Reduce Image Size to 100KB Without Losing Quality

How to Reduce Image Size to 100KB Without Losing Quality The visa portal wants your photo under 100KB. Yours is 312KB. You drag the quality slider down to 70, export, and get 88KB, but your face looks…

  • Focus on target file size, not quality slider
  • Target-size encoder finds highest quality under 100KB cap
  • Tools like SnapShrink adjust image to meet size limit

Invisible spaces and the #N/A they cause

Disclosure: This is the English edition of an explainer I originally made in Japanese. It was translated with AI assistance, then reviewed and edited. Every example below uses dummy data.

  • Invisible spaces cause VLOOKUP to return #N/A despite identical appearance
  • LEN function identifies hidden spaces by counting characters in cells
  • Full-width space can mimic regular space and disrupt lookups

More from Wednesday 25 November →