Skip to content

feat: Expo SDK 52+ support - migrate to new expo-sqlite API#1

Merged
cedrvanh merged 8 commits intomasterfrom
expo-sdk-52-sqlite-migration
Feb 27, 2026
Merged

feat: Expo SDK 52+ support - migrate to new expo-sqlite API#1
cedrvanh merged 8 commits intomasterfrom
expo-sdk-52-sqlite-migration

Conversation

@cedrvanh
Copy link

@cedrvanh cedrvanh commented Feb 27, 2026

Summary

Migrates the package from expo-sqlite legacy API to the new async API required for Expo SDK 52+.

Changes

  • Database.ts: Replaced expo-sqlite/legacy with expo-sqlite
    • openDatabase()openDatabaseAsync()
    • transaction(callback)withTransactionAsync()
    • deleteAsync()SQLite.deleteDatabaseAsync()
  • DatabaseLayer.ts: Updated to use new async methods
    • runAsync() for INSERT/UPDATE/DELETE (returns lastInsertRowId)
    • getAllAsync() for SELECT queries
  • package.json:
    • peerDependencies: expo-sqlite ^14.0.0 || ^15.0.0
    • devDependencies: expo-sqlite ^15.0.0
  • Version: Bumped to 3.0.0 (breaking change)

Breaking change

This drops support for Expo SDK 50 and the legacy expo-sqlite/legacy API. Projects must use Expo SDK 51+ with the new expo-sqlite API.

Made with Cursor

Summary by CodeRabbit

  • Breaking Changes

    • Upgraded to Expo SQLite new API; requires Expo SDK 51+ and expo-sqlite 14.0.0+
    • All database methods are now async-first with Promise-based returns
    • Replaced Database.transaction() with Database.withTransactionAsync()
    • Package scope changed to @esign/expo-sqlite-orm; update installation and imports
  • New Features

    • Enhanced type safety for SQL parameters
    • Improved transaction error handling
    • See CHANGELOG.md for detailed migration guide

- Replace expo-sqlite/legacy with expo-sqlite (new async API)
- Use openDatabaseAsync, runAsync, getAllAsync, withTransactionAsync
- Use deleteDatabaseAsync for database reset
- Update peerDependencies to support expo-sqlite ^14.0.0 || ^15.0.0
- Bump version to 3.0.0 (breaking change)
- Update mocks and tests for new API

Made-with: Cursor
- Fix unsafe non-null assertion in withTransactionAsync with proper error handling
- Improve type safety for executeBulkSql params (any[] -> (any[] | undefined)[])
- Add comprehensive tests for withTransactionAsync error cases
- Add CHANGELOG.md documenting v3.0.0 breaking changes and migration guide

Made-with: Cursor
- Add prominent notice explaining this is a fork of expo-sqlite-orm
- Explain why fork was created (Expo SDK 52+ support)
- Update all import examples to use @esign/expo-sqlite-orm
- Update install instructions with correct package name
- Add link to CHANGELOG.md for detailed migration info
- Update credits section to acknowledge original author

Made-with: Cursor
- Replace 'yarn' with 'npm ci' for dependency installation
- Replace 'yarn test' with 'npm test'
- Replace 'yarn build' with 'npm run build'
- Use npm ci for faster, more reliable CI builds

Made-with: Cursor
Add condition to publish-npm job to only run on push to master branch.
This prevents the job from being evaluated/triggered on pull request events,
ensuring publishing only happens when code is merged to master.

Made-with: Cursor
@cedrvanh
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Feb 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4e7bb99 and 6264478.

⛔ Files ignored due to path filters (2)
  • package-lock.json is excluded by !**/package-lock.json
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (12)
  • .github/workflows/npm-publish.yml
  • CHANGELOG.md
  • README.md
  • __mocks__/expo-sqlite/index.ts
  • __tests__/Database.test.ts
  • __tests__/DatabaseLayer.test.ts
  • __tests__/Migrations.test.ts
  • package.json
  • setupTests.js
  • src/Database.ts
  • src/DatabaseLayer.ts
  • tsconfig.json

📝 Walkthrough

Walkthrough

This PR migrates the project to the new Expo SQLite async API (SDK 51+), bumps the major version to 3.0.0, converts all database operations to async-first patterns with a new withTransactionAsync method, updates CI from Yarn to npm, and updates documentation to reflect these breaking changes.

Changes

Cohort / File(s) Summary
CI/CD Configuration
.github/workflows/npm-publish.yml
Removed pull request trigger for master branch; replaced Yarn commands (yarn, yarn test, yarn build) with npm equivalents (npm ci, npm test, npm run build).
Documentation & Release Notes
README.md, CHANGELOG.md
Added fork notice and rationale; updated installation to reference @esign/expo-sqlite-orm package; added prerequisites for Expo SDK 51+ and expo-sqlite 14.0.0+; introduced Credits section with fork maintainer details; added comprehensive 3.0.0 release entry documenting breaking changes, new async APIs, migration guide, and enhanced type safety.
Configuration & Setup
package.json, tsconfig.json, setupTests.js
Bumped version to 3.0.0; updated expo-sqlite devDependency to ^15.0.0 and peerDependency to ^14.0.0 || ^15.0.0; added src/__mocks__ to tsconfig exclude; added expo-sqlite mock to setupTests.
Core Database Abstraction
src/Database.ts
Replaced synchronous openDatabase() with async getDatabase() using lazy-loaded promise; removed transaction() method; introduced withTransactionAsync<T>() for executing async callbacks within transactions; added runSql() and runBulkSql() for async SQL execution returning rows and insertIds; updated close() and reset() to async with proper cache clearing.
Database Layer
src/DatabaseLayer.ts
Converted all public methods (insert, update, bulkInsertOrReplace, destroy, destroyAll, find, findBy, query) to async; refactored executeBulkSql() to accept (any[] \| undefined)[] parameters; updated parameter handling to use new runBulkSql() API; ensured methods await execution and return typed results.
Test Infrastructure & Mocks
__mocks__/expo-sqlite/index.ts, __tests__/Database.test.ts, __tests__/DatabaseLayer.test.ts, __tests__/Migrations.test.ts
Replaced legacy openDatabase mock with new mockDb exposing getAllAsync(), runAsync(), closeAsync(), and withTransactionAsync(); introduced openDatabaseAsync() and deleteDatabaseAsync() exports; added comprehensive test suite for Database reset and withTransactionAsync behavior; updated DatabaseLayer and Migrations tests to use new async mocks and assert on async calls.

Sequence Diagram

sequenceDiagram
    participant Consumer
    participant DatabaseLayer
    participant Database
    participant expo-sqlite as expo-sqlite API

    Consumer->>DatabaseLayer: insert(obj) / update(obj) / query(options)
    activate DatabaseLayer
    DatabaseLayer->>Database: getDatabase()
    activate Database
    Database->>expo-sqlite: openDatabaseAsync()
    expo-sqlite-->>Database: SQLiteDatabase
    Database-->>DatabaseLayer: Promise<SQLiteDatabase>
    deactivate Database
    
    DatabaseLayer->>Database: withTransactionAsync(fn)
    activate Database
    Database->>expo-sqlite: db.withTransactionAsync(callback)
    activate expo-sqlite
    expo-sqlite->>Database: Execute transaction
    Database->>Database: fn(db)
    Database-->>expo-sqlite: Return result
    expo-sqlite-->>Database: Transaction complete
    deactivate expo-sqlite
    Database-->>DatabaseLayer: Promise<T>
    deactivate Database
    
    DatabaseLayer->>expo-sqlite: runAsync / getAllAsync
    expo-sqlite-->>DatabaseLayer: Results
    deactivate DatabaseLayer
    
    DatabaseLayer-->>Consumer: Promise<Result>
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes


🐰 From legacy to async, we hop with glee,
Transactions now flow through promises, wild and free,
npm builds our path, SDK fifty-one's the way,
3.0.0 brings breaking changes, but cleaner code to play!
✨🛢️✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch expo-sdk-52-sqlite-migration

Comment @coderabbitai help to get the list of available commands and usage tips.

@cedrvanh cedrvanh merged commit 8d6bc4e into master Feb 27, 2026
@cedrvanh cedrvanh deleted the expo-sdk-52-sqlite-migration branch February 27, 2026 15:34
@cedrvanh cedrvanh restored the expo-sdk-52-sqlite-migration branch February 27, 2026 15:47
cedrvanh added a commit that referenced this pull request Feb 28, 2026
feat: Expo SDK 52+ support - migrate to new expo-sqlite API
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant