|
| 1 | +## Upgrading `package:sqlite3`. |
| 2 | + |
| 3 | +This document collects notes on upgrading the `sqlite3` package from version |
| 4 | +2.x to version 3.x. |
| 5 | + |
| 6 | +For almost all users, upgrading should be very simple: |
| 7 | + |
| 8 | +1. If you depend on `sqlite3_flutter_libs`, stop doing that. |
| 9 | +2. If you depend on `sqlcipher_flutter_libs`, stop doing that and read |
| 10 | + [encryption](#encryption). |
| 11 | +3. Upgrade to `sqlite3: ^3.0.0`. |
| 12 | +4. Make sure you update your `sqlite3.wasm` by downloading it from the |
| 13 | + [latest releases](https://github.com/simolus3/sqlite3.dart/releases). |
| 14 | +5. If you had `open.overrideFor` code to customize how SQLite is loaded, that needs |
| 15 | + to be removed. The package exclusively uses hooks now. |
| 16 | + |
| 17 | +Version 3.x relies on [hooks](https://dart.dev/tools/hooks) to automatically bundle |
| 18 | +a pre-compiled version of SQLite with your application. By default, these binaries |
| 19 | +are downloaded from the GitHub releases of this package. |
| 20 | +This mechanism replaces the earlier scheme based on platform-specific build |
| 21 | +scripts. |
| 22 | + |
| 23 | +If you want to compile SQLite yourself instead of relying on those downloaded |
| 24 | +binaries, see [custom SQLite builds](#custom-sqlite-builds). |
| 25 | + |
| 26 | +Also note that the build definition for `sqlite3.wasm` has changed. New sources |
| 27 | +are available in [sqlite3_wasm_build](./sqlite3_wasm_build/). |
| 28 | + |
| 29 | +## Encryption |
| 30 | + |
| 31 | +If you've been using SQLCipher to use encrypted databases, note that SQLCipher is |
| 32 | +no longer available with version 3. However, a precompiled version of SQLite3MultipleCiphers |
| 33 | +can easily be enabled by adding this to your pubspec: |
| 34 | + |
| 35 | +```yaml |
| 36 | +hooks: |
| 37 | + user_defines: |
| 38 | + sqlite3: |
| 39 | + source: sqlite3mc |
| 40 | +``` |
| 41 | +
|
| 42 | +SQLite3MultipleCiphers should be compatible with existing databases created by SQLCipher when running the following statements from SQLite3MultipleCiphers: |
| 43 | +
|
| 44 | +``` |
| 45 | +pragma cipher = 'sqlcipher'; |
| 46 | +pragma legacy = 4; |
| 47 | + |
| 48 | +pragma key = '...your key...'; |
| 49 | +``` |
| 50 | + |
| 51 | +For details, see [hook options](./sqlite3/doc/hook.md). |
| 52 | + |
| 53 | +## Custom SQLite builds |
| 54 | + |
| 55 | +If you want to customize the SQLite build for `package:sqlite3`, there are two options: |
| 56 | + |
| 57 | +1. Downloading `sqlite3.c` into your project and then following the "Custom SQLite builds" |
| 58 | + section of [hook options](./sqlite3/doc/hook.md). |
| 59 | +2. Using external build scripts (such as SwiftPM or CMake) to statically link SQLite into your |
| 60 | + Flutter application, and then following the "Alternatives" section of [hook options](./sqlite3/doc/hook.md). |
| 61 | + |
| 62 | +For details, see [hook options](./sqlite3/doc/hook.md). |
| 63 | + |
| 64 | +If these customization options don't meet your needs, please open an issue! |
0 commit comments