◉RORK LABJP
●EXPO — EAS Observe now records native crashes (Oct 7). On SDK 57, update to 57.0.21 or later●SDK 58 — SDK 58 Beta has been out since Sep 15. The stable date is still unconfirmed●RN 0.88 — React Native 0.88.x is scheduled for Oct 12, 3 days left●Q&A — People are asking why expo-widgets render blank only in production builds●RORK — GPT-6.1 Sol was added on Sep 29, available on Pro and Max plans●NEW — Building an app for a client? Decide who owns the publishing account first●EXPO — EAS Observe now records native crashes (Oct 7). On SDK 57, update to 57.0.21 or later●SDK 58 — SDK 58 Beta has been out since Sep 15. The stable date is still unconfirmed●RN 0.88 — React Native 0.88.x is scheduled for Oct 12, 3 days left●Q&A — People are asking why expo-widgets render blank only in production builds●RORK — GPT-6.1 Sol was added on Sep 29, available on Pro and Max plans●NEW — Building an app for a client? Decide who owns the publishing account first
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 $15 for lifetime access
View Membership →

Related Articles

⬡ Dev Tools2026-10-07
Japanese Headings Won't Turn Bold on Android: How to Trace and Fix a fontWeight That Does Nothing
A troubleshooting note for Rork apps where headings look bold on iPhone but stay thin on Android. How to tell the symptoms apart, pick weights through fontFamily, and verify the fix.
⬡ Dev Tools2026-09-22
Four Numbers to Record Before R8 Becomes the Default — Android Measurements While We Wait for Expo SDK 58
Expo SDK 58 turns on R8 by default for Android release builds. Here is how I capture four numbers — download size, DEX total, cold start, and build time — so the before and after can be compared with the same ruler.
⬡ Dev Tools2026-09-21
A build that stops with exit code 0 — the flag that silenced the log, and the check that let an empty file through
Two reports landed in the same week: eas build --local stopping with exit code 0 but produced no further output, and a zero-byte stub that never got embedded. Both came down to settings that reduce output. Here is how to audit your own scripts.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links