◉RORK LABJP
●ARCHIVE — Since 11/22 you can archive a Rork project instead of deleting it, and bring it back from Archived●PLAY FIX — Fixed: Expo apps built for Google Play losing their Rork AI key, which broke AI features●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 7 days left. Check which model your app calls●SPLASH — Expo users report apps stuck on the splash screen after rolling back to an earlier update●NEW — New: Three clues to check before replying to a "stuck on the splash screen" review●2.5 ROUTE — From 12/1, Gemini 2.5 requests reroute to newer models at new rates. 8 days left●ARCHIVE — Since 11/22 you can archive a Rork project instead of deleting it, and bring it back from Archived●PLAY FIX — Fixed: Expo apps built for Google Play losing their Rork AI key, which broke AI features●SONNET 4.5 — Sonnet 4.5 retires from the Claude API on 11/30, 7 days left. Check which model your app calls●SPLASH — Expo users report apps stuck on the splash screen after rolling back to an earlier update●NEW — New: Three clues to check before replying to a "stuck on the splash screen" review●2.5 ROUTE — From 12/1, Gemini 2.5 requests reroute to newer models at new rates. 8 days left
Articles/Dev Tools
⬡ Dev Tools/2026-07-05Advanced

Changing a Table Without Wiping User Data in Rork's expo-sqlite — A PRAGMA user_version Migration Runner

A crash on launch, only for existing users: no such column. That is what happens when you ship a table-structure change to installs that still hold the old schema. Here is the expo-sqlite migration layer I put in every Rork app, built on PRAGMA user_version, with the full runner and the operational rules behind it.


✦ Premium Article

Right after I shipped a new version, unfamiliar crashes started stacking up in Crashlytics: no such column: added_at. My simulator had never produced it once. The only devices going down were those that had updated from a previous version.

The cause was quick to spot. The new code runs SELECT id, wallpaper_id, added_at FROM favorites. But the SQLite file on an existing user's device has no added_at column yet. Fresh installs are fine, because the app runs its CREATE TABLE on first launch and gets the new column. That is exactly why store review passed and my own testing passed. The gap only appears for people who updated while carrying the old schema on disk.

On a server database, changing the schema means writing a migration and running it as part of the deploy. The SQLite file on the device needs the same discipline. I covered the key-value side of this in a separate piece on local data migration for Rork apps, but relational SQLite is a step trickier, because you are changing the table structure itself. Here is the ordered migration layer I run in Rork apps, with the full implementation.

Why SQLite migrations are trickier than AsyncStorage

With AsyncStorage, you can reshape the parsed JSON in code right after you read it. The read boundary is a single point. SQLite is not like that. The schema — the table definitions — is baked into the file on the device, and the moment your code's expectations diverge from what the file actually holds, the query fails at runtime.

On top of that, SQLite's ALTER TABLE is limited. You can add a column, but dropping a column, renaming one, or changing a constraint like UNIQUE or NOT NULL cannot be written as a single clean statement. You have to rebuild the whole table. If you do not know about this asymmetry and assume "I'll just ALTER TABLE it," you get stuck halfway through.

There is a second trap: even within one app, the schema version differs from user to user. A device sitting on v1 can wake up half a year later and meet v4 code for the first time. So a migration has to be shaped so it can apply one step at a time and reach the latest schema no matter where it starts.

The whole design hinges on one integer: PRAGMA user_version

SQLite ships with an integer field you can write into the database file header: PRAGMA user_version. Your app can use it as a marker for "how far along is this file's schema." A freshly created database reads 0.

The logic is simple. Compare the latest version your app knows about (the number of migrations) with the file's user_version, apply only the missing steps in order, and bump user_version by one each time you apply a step. That alone makes every generation of device converge on the same target. You can also keep a version table inside the database, but user_version lives in the file and needs no extra query, so it is the option I reach for.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦You'll get the full TypeScript implementation of a migration runner that fills in every version in order using expo-sqlite's PRAGMA user_version
✦You'll be able to tell an ADD COLUMN change apart from one that needs a 12-step table rebuild, so column drops, renames, and constraint changes ship safely
✦You'll avoid the silent data loss that happens when foreign keys and transactions collide, by knowing when to turn foreign_keys off and how to verify with foreign_key_check
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ Dev Tools2026-11-19
New Wallpapers Showed Up Everywhere Except the Filters: Ship the Count and the Category Lists Together
I added 67 wallpapers in one batch. They appeared in the full list and in New, but not under a single category filter, because I had raised the ID limit and forgotten to ship the category lists. Here is a pre-bump check, a client-side way to spot silent fallbacks in an Expo app, and a post-release count against the origin.
⬡ Dev Tools2026-11-11
On Android, expo/fetch can return a cut-off response as a success — why I read the body as a stream
If the connection drops mid-response, Android's expo/fetch can still resolve text() with the partial string. Here is why it looks like a JSON SyntaxError, and a short stream-reading helper.
⬡ Dev Tools2026-11-04
Catching the Few Seconds Before Streaming Audio Starts: A Loading State and a Timeout
You tap play and nothing happens for a moment. Here is how I model that gap with expo-audio: a requested flag, a 400ms delayed spinner, and an 8-second timeout.