RORK LABJP
FUNDING — Rork closed a $15M seed round led by Left Lane Capital, with Peak XV, True Ventures, Goodwater, and a16z SpeedrunUSERS — Rork now reaches 2M users with 743K monthly visits and an 85% growth rateMAX — Rork Max generates native Swift apps for iPhone, iPad, Watch, TV, Vision Pro, and iMessageSTACK — Standard Rork builds iOS and Android together in React Native (Expo), so non-engineers can ship real appsPRICE — Plans start free, paid tiers from $25/month, and Rork Max at $200/monthMARKET — Gartner projects 75% of new apps will be low-code or no-code by the end of 2026FUNDING — Rork closed a $15M seed round led by Left Lane Capital, with Peak XV, True Ventures, Goodwater, and a16z SpeedrunUSERS — Rork now reaches 2M users with 743K monthly visits and an 85% growth rateMAX — Rork Max generates native Swift apps for iPhone, iPad, Watch, TV, Vision Pro, and iMessageSTACK — Standard Rork builds iOS and Android together in React Native (Expo), so non-engineers can ship real appsPRICE — Plans start free, paid tiers from $25/month, and Rork Max at $200/monthMARKET — Gartner projects 75% of new apps will be low-code or no-code by the end of 2026
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-07-04
Your Rork Max App Loses the Photos a User Picked After Relaunch — The Trap of Holding Onto URLs Under Limited Photo Access
In a native Swift app generated by Rork Max, photos picked via PHPickerViewController become unreadable after relaunch — because holding onto a URL or PHAsset no longer works in the age of limited access. Here's a design that copies the actual bytes into your own storage the instant they're picked.
Dev Tools2026-07-04
Start a Live Activity Without Launching Your Rork Max App — Designing Around a push-to-start Token That Never Arrives
In a native Swift app generated by Rork Max, you want to start a Live Activity from your server without the user ever opening the app. But the push-to-start token is never observed and it fails silently. Here's the cause and an observation layer that reliably captures the token.
Dev Tools2026-07-04
Your Rork Max Health App Misses Overnight Steps — Designing Background Delivery When HKObserverQuery Dies Silently
In a native Swift health app generated by Rork Max, data recorded while the app is closed never arrives — and it's almost always because HKObserverQuery's background delivery stopped without a word. Here's how to isolate the layer that broke and an observation layer you can drop in as-is.
📚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
See all →