DatabasesOct 24, 2026·9 min read

Why Your Prototype Lost All Data on Redeploy: Ephemeral SQLite on Cloud Hosts

A friend pushed a one-character CSS fix to Railway and wiped all 180 registered beta users. Here is why AI tools default to local SQLite, and how we migrated to Postgres.

#SQLite#PostgreSQL#Vercel#Railway#Data Loss#Drizzle#Prisma

01Run this check right now

Diagnostic Test

The 10-Second SQLite Connection Check

Run this command in your repository root. If your project connects to a local file such as file:./dev.db or sqlite.db, any deployment to serverless or container hosts will wipe your runtime database whenever you push new code.

grep -rnE "(better-sqlite3|sqlite3|libsql|file:.*\.db)" src/ package.json .env*

Findings from the Field

  • /01AI assistants default to SQLite because in-process file storage skips credentials and network setup during initial prompts.
  • /02Cloud hosts run stateless, immutable containers: pushing a Git commit tears down the old container and deletes all runtime disk writes.
  • /03A single CSS commit wiped 180 registered beta users because the SQLite file lived inside the container image.
  • /04How to dump existing SQLite records, update ORM drivers to PostgreSQL, and push schemas to managed database providers.
  • /05Verifying that the production build writes to persistent cloud storage across container reboots.

The one-character commit that wiped 180 users

A friend pinged me in a panic on a Sunday afternoon. They had spent the weekend building a niche community directory using Cursor and deployed it to Railway. It gained traction on Twitter: 180 people created profiles, added bio links, and bookmarked listings. Everything was humming along.

Then my friend noticed a minor typo in the footer copy, fixed the character in VS Code, and ran `git commit -am 'fix footer typo' && git push`. Railway picked up the commit, rebuilt the container, and went live. Thirty seconds later, every user account, profile, and bookmark had completely vanished. The database had reset back to the initial blank seed state.

I jumped into a terminal session with them to reconstruct what happened. It was the classic ephemeral filesystem surprise.

Why AI tools love SQLite

When you prompt an AI model to build an application, its primary heuristic is eliminating friction. Setting up external PostgreSQL or MySQL requires connection strings, environment variables, credentials, and network configuration. SQLite requires none of that.

SQLite is a C library that embeds directly into your application process and writes to a local file on disk, usually named `dev.db` or `sqlite.db`. It runs instantaneously, has zero setup overhead, and passes all local tests on your laptop.

Because the file sits on your physical hard drive, it survives your dev server restarts. It gives the developer the illusion that persistence is solved.

The Etch-a-Sketch analogy

Think of modern container platforms like an Etch-a-Sketch. You can draw a very detailed picture on the screen while you sit at your desk. But the moment someone picks up the toy and carries it into another room, the internal beads shake and the screen resets to a blank gray slate.

On platforms like Railway, Render, Fly.io, and Vercel, web servers run inside disposable containers or serverless sandboxes. When you push a Git commit, the platform builds a new container image and terminates the old one. Any file written to the container disk at runtime is destroyed with the old container.

Checking your codebase in 10 seconds

You can verify your database connection model with a single terminal command:

If you see `better-sqlite3` in your package.json or `file:./dev.db` in your drizzle or prisma config, your database lives on disposable disk.

Terminal driver auditbash
grep -rnE "(better-sqlite3|sqlite3|libsql|file:.*\.db)" src/ package.json .env*

Step 1: Rescue data before the next redeploy

If users have already registered on your live app, do not push another commit yet. Connect to the running container shell and export the SQL dump directly to your local machine:

Container SQLite dumpbash
sqlite3 /app/dev.db .dump > backup_users.sql

Step 2: Swap the ORM driver to PostgreSQL

Next, install the PostgreSQL driver and remove the in-process SQLite engine:

Terminal dependency updatebash
bun remove better-sqlite3
bun add postgres
bun add -D @types/postgres

Step 3: Point ORM configuration to DATABASE_URL

Update your `drizzle.config.ts` or Prisma schema to connect over the network using `DATABASE_URL`:

Hardened drizzle.config.tstypescript
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "postgresql",
  schema: "./src/db/schema.ts",
  dbCredentials: {
    url: process.env.DATABASE_URL!,
  },
});

Step 4: Push schema to a managed database

Provision a managed PostgreSQL instance on Supabase, Neon, or Railway Postgres. Set the `DATABASE_URL` in your deployment dashboard, and push the schema directly:

Drizzle schema pushbash
npx drizzle-kit push

Reflections: persistence belongs across the network

Once we pushed the schema to Neon and redeployed the frontend, we verified the persistence by killing the container intentionally three times. Every user record remained intact.

Local SQLite is fantastic for CLI tools, embedded devices, and single-user desktop software. But the moment your application runs on modern cloud infrastructure, your database must live on a dedicated network instance with persistent volume attachments.

Now I can close this terminal tab and go make some lunch, because yolo.

Production Hardening & Audits

Stuck on prompt regressions, leaked keys, or database scaling in an AI-built app? Explore our platform-specific teardowns:

Diagnostic & Rescue

1 business day reply

Think your prototype is vulnerable or hitting scale limits?

Send us a note with your repository, Supabase link, or project details. A senior engineer will review your policies and reply within one business day.