(Note · · 7 min read)

Changing a live system you did not build, without losing a record

Inheriting software that already has customers is a different job from building it. The code is not the risk; the fact that it is running is. From a takeover of a seven-hotel booking platform with live reservations and payments, here is how to make changes you can prove were safe.

By Md. Habibur Rahman Shohel, full-stack & AI product engineer in Dhaka

Map control before you touch code

The first question is not what the code looks like. It is what happens if the person who built it disappears tomorrow. Who owns the repository, the hosting, the domain, the database, the payment account? Being added as a collaborator on someone else's repository is not ownership; it can be removed with one click. Settle that first, because every technical decision afterwards assumes you can actually deploy.

Then find out what is really running. The deployed build and the newest commit are not always the same thing, and on an inherited system they frequently are not. On the platform I took over, one hotel's site had been deployed from another property's build, still carried that property's identity across 34 files, and had never finished building, so it was returning server errors in production. Nothing in the repository said so.

Assume there is no safety net, because there usually is not

That platform had no staging environment and no migration history: the database had been created without one. So any schema change would run directly against live reservations, with nothing to rehearse against and nothing to compare the result to.

You build the net yourself before you need it. A complete local copy of the system — every application, the API, and the database restored from a real backup — turns a guess into a rehearsal. It costs a day and it is the difference between a change you believe is safe and a change you have watched succeed on real data.

A backup you have not restored is not a backup. Restoring it is the only way to learn that it was incomplete, that it is missing a table, or that nobody has ever tested the procedure. Do that before the work, not during the incident.

Make the migration incapable of losing data

The safest schema change is one that only adds. Adding three tables and dropping nothing cannot destroy a reservation, whatever else goes wrong, and it leaves the old shape intact to fall back to. Write the migration so that it is additive, have someone read it, and rehearse it on a restored copy of production before it runs for real.

Moving existing content into a new structure deserves the same discipline. When hard-coded content became database-driven on that platform — 20 features, 24 attractions, 139 service assignments and 124 images — the check was not that the migration script exited cleanly. It was comparing every section of every live hotel against production until they matched item for item.

Tests that name the promise they keep

On an inherited codebase you cannot write a test suite for everything, and you do not need one. You need tests for what you promised. That takeover was covered by 46 automated checks, each one naming the requirement it proves, so the question at the end was not whether coverage looked healthy but whether every line of the brief had something standing behind it.

This also protects you commercially. When a client asks whether the thing they paid for actually works, a named check per requirement is an answer. A coverage percentage is not.

Deploy behind a door, and count everything twice

For the release itself: a maintenance page, then gated steps that each have to succeed before the next begins. Backup taken, then verified by a full restore. Migration run. Applications deployed. And around the whole window, a checksum of every table before and after.

That last step is what converts a claim into evidence. Across a deployment that touched ten applications and a live booking database, the before-and-after checksums showed that not one booking, payment, user or inventory record had changed. Without them, the honest statement would have been that nothing appeared to break.

Stabilise first, rewrite later or never

The instinct on inheriting messy software is to rewrite it. Resist it until you understand what the business actually depends on, because the mess often encodes a rule nobody wrote down, and a rewrite deletes the rule along with the mess.

Fix what is bleeding instead. On that system a payment refused by the gateway surfaced to guests as a generic error and left an unpaid booking behind. The repair was small and specific: ask the gateway for a payment page first, create the reservation only when one comes back, and pass the gateway's actual reason to the guest. No rewrite, one broken path closed.

Where duplication is the problem, consolidate at the point where a fix would otherwise have to be made twice. Seven sites built from copies of one codebase meant one change had to be made, built and verified seven times. The answer was not a rewrite into one application; it was a shared admin layer for the things that are genuinely the same, so a fix lands everywhere at once.

The order that works

  1. Secure ownership of the repository, hosting, domain, database and payment accounts. Rotate every credential the previous developer held.
  2. Identify the exact build that is in production and how a release actually happens today.
  3. Take a backup and restore it somewhere else to prove it works.
  4. Stand up a full local copy from that restored data, since there is probably no staging.
  5. Rehearse every schema change there, and keep migrations additive.
  6. Write one named check per promise you have made.
  7. Release behind a maintenance page with gated steps, and checksum every table before and after.
  8. Only once it is stable, discuss what is worth rewriting.

Common questions

What should I check first when taking over someone else's live application?

Control, not code. Confirm who owns the repository, hosting, domain, database and payment accounts, and rotate every credential the previous developer held. Collaborator access to a repository you do not own can be revoked in one click, so it is not a handover.

How do I change a database schema when there is no staging environment?

Build one. Restore a real backup into a complete local copy of the system and rehearse the migration there. Keep the migration additive — adding tables and dropping nothing cannot destroy existing records — and have someone review it before it runs against production.

How can I prove a deployment did not damage live data?

Checksum every table before and after the release window. On the hotel platform takeover, a deployment across ten applications and a live booking database was verified this way: the before-and-after checksums showed not one booking, payment, user or inventory record had changed. Without that, the strongest honest claim is that nothing appeared to break.

Should I rewrite an inherited codebase?

Not before you understand what the business depends on. Messy code often encodes rules nobody documented, and a rewrite removes them along with the mess. Stabilise the broken paths first, consolidate only where a fix would otherwise have to be made twice, and treat a rewrite as a separate decision made later.

How many tests does an inherited codebase need?

Enough to cover what you promised, not everything. Writing one named check per requirement in the brief means you can show that each promise has something standing behind it, which is more useful to a client than a coverage percentage.

Is a backup enough before a risky deployment?

Only if you have restored it. A backup nobody has restored is untested, and a release is the worst time to discover it is incomplete. Restore it somewhere else first, then treat the verified restore as the gate the deployment has to pass before it begins.

Need something like this built?