Moving a live CRM from SQLite to PostgreSQL, compared response by response

We rehearsed the switch on a copy of production, ran old and new side by side and compared every page. The real switch closed the CRM for two minutes.

The short answer

We rehearsed the full switch on a throwaway copy of production, ran the old SQLite version and the new PostgreSQL version side by side on the same data, and compared their answers page by page until there was no difference. On the day, the CRM was closed for two minutes, the copied data matched table by table, and the old database stayed ready as a way back.

On this page
  1. Why move off SQLite at all?
  2. How did we prepare?
  3. How did we know the new version was right?
  4. How did the day go?
  5. What was the way back?
  6. What changed for backups?
  7. What we’d tell anyone doing the same

One of the CRMs we run started on SQLite, with uploaded files on the server’s disk. It worked, but it tied the app to one machine: the database and the files lived next to the app, so a second server or a quick move to new hardware wasn’t possible. In November 2026 we moved it to PostgreSQL, with files in S3-compatible object storage.

The CRM is used every day, so the switch had to be short, and nothing could go missing. This post covers how we prepared, how we proved the new version gave the same answers, and how the day went.

Why move off SQLite at all?

SQLite is a fine database. The problem was where the state lived. The rule we now follow for every server app is that nothing important lives on the app container’s disk: data in PostgreSQL, files in object storage through the S3 API. Then any copy of the app can run on any server, and adding a second server later needs no code change.

How did we prepare?

We split the work into three parts, each of which could be stopped without harm.

  1. Install first, use later. PostgreSQL and the object store were installed on the server and left unused while the CRM kept running on SQLite. Nothing changed for users.
  2. A full rehearsal on a copy. A separate, throwaway set-up with its own database and bucket, no public address, and a fresh snapshot of production. It ran the old SQLite version and the new PostgreSQL version side by side, each on the same data.
  3. The window. A short planned closure for the real switch, with a written stop point: up to the moment the CRM runs on PostgreSQL, the switch can be called off and the old version reopened.

How did we know the new version was right?

Tests check the cases someone thought of. A migration breaks on the data nobody thought of. So in the rehearsal we compared the two versions’ answers: the same pages and the same API calls, signed in as the same user, old against new.

The first comparison found one difference: an earnings page listed some commission rows in a different order. The cause was a query that relied on the order SQLite happened to return rows in; PostgreSQL makes no such promise without an explicit ORDER BY. We fixed it before the switch. The second comparison found no differences.

The rehearsal mustn’t do anything real, because it runs on real data. The background worker that sends reminders and other messages never ran there, and sending was switched off in its settings. The copy held personal data, so the last step of the rehearsal deleted it.

How did the day go?

  • The CRM showed a maintenance page while the final snapshot was copied.
  • The copy was checked table by table with checksums; the data was identical.
  • The CRM was closed for two minutes and then reopened on PostgreSQL.
  • The owner checked the live site, and only then was the background worker started again.

The rehearsal also told us what to expect from the server: the rehearsal’s databases used about 250 MB of memory, well within what the server had free.

What was the way back?

The old SQLite database, its last image and its replica were kept untouched for nine days. Any serious problem in that time meant redeploying the old image on the old data. Nothing needed it, and the way back was then closed on purpose and the old data archived.

What changed for backups?

A backup now holds the database dump and every stored file together in one file. It counts as a backup only after a restore into a throwaway database and bucket has worked. We now run that restore every night.

What we’d tell anyone doing the same

  • Rehearse on a real copy, not on test data. The one bug we found came from real rows.
  • Compare outputs, not just row counts. Same pages, same user, old against new.
  • Write the stop point down before the window. It’s much easier to call off a switch that has a written rule for when to call it off.
  • Keep the way back for a fixed time, then close it on purpose.

Keep reading

Tell us what you want to build.

A product, a website, a search problem or a system that should work better. We reply with a plain answer and the first step.

A few sentences are enough (at least 20 characters).

We use your details only to answer your inquiry. See our privacy policy.