@supabase/lite 0.0.1 → 0.2.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +311 -0
- package/STATUS.md +844 -0
- package/UPGRADE.md +221 -0
- package/dist/cli/index.js +330 -29421
- package/dist/cli/lib.js +49 -6273
- package/dist/db/browser/index.js +19 -15485
- package/dist/db/bun/index.js +19 -15473
- package/dist/db/fallback.js +18 -15369
- package/dist/db/node/index.js +19 -15466
- package/dist/db/postgres/PostgresConnection.js +18 -365
- package/dist/db/postgres/pglite/PgliteConnection.js +20 -642
- package/dist/db/workerd/index.js +18 -15591
- package/dist/index.js +258 -32242
- package/dist/vite/index.js +3 -1910
- package/package.json +8 -9
- package/dist/Connection-BJclIu8v.d.ts +0 -529
- package/dist/Connection-BsiQMo4A.d.ts +0 -562
- package/dist/db/postgres/BasePostgresConnection-COHRCvc-.d.ts +0 -24
- package/dist/db/postgres/BasePostgresConnection-Di94o0ON.d.ts +0 -24
- package/dist/db/postgres/index.js +0 -802
- package/dist/db/sqlite/index.js +0 -14724
- package/dist/index-4cbfQyFv.d.ts +0 -763
package/UPGRADE.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Upgrade to Supabase
|
|
2
|
+
|
|
3
|
+
This document describes the current `lite upgrade` behavior. It is intended for both users and LLM agents working on the upgrade path.
|
|
4
|
+
|
|
5
|
+
Supalite is designed as a lightweight starting point with a path to full Supabase. The upgrade command exports the local Supalite project, rehearses it against Postgres-compatible execution, and applies it to a Supabase target.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
Hosted Supabase is the default target:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
lite upgrade
|
|
13
|
+
lite upgrade --target hosted
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Use `--dry-run` first to check readiness and rehearse the generated SQL without creating or changing a Supabase target:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
lite upgrade --dry-run
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Use `--force` to skip the interactive confirmation:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
lite upgrade --force
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Write generated credentials to a JSON file:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
lite upgrade --force --dump-credentials ./supabase-credentials.json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Targets
|
|
35
|
+
|
|
36
|
+
### Hosted Supabase
|
|
37
|
+
|
|
38
|
+
`--target hosted` is the default. It creates a new hosted Supabase project through the Supabase Management API, waits for it to become healthy, applies schema/auth/data, fetches API keys, and prints the new project details.
|
|
39
|
+
|
|
40
|
+
Relevant options:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
lite upgrade \
|
|
44
|
+
--target hosted \
|
|
45
|
+
--org-id <organization-id-or-slug> \
|
|
46
|
+
--region <region-key> \
|
|
47
|
+
--project-name <name> \
|
|
48
|
+
--supabase-token <personal-access-token>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
If `--supabase-token` is omitted, `SUPABASE_ACCESS_TOKEN` is used. If required hosted values are omitted in an interactive shell, the CLI prompts for them.
|
|
52
|
+
|
|
53
|
+
Only `--mode user` is currently supported. `--mode platform` is reserved for future work.
|
|
54
|
+
|
|
55
|
+
### Local Supabase
|
|
56
|
+
|
|
57
|
+
`--target local` upgrades into a local Supabase CLI workdir. By default, the workdir is the current directory, so the command initializes or updates `./supabase/config.toml` in the project being upgraded:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
lite upgrade --target local --force --no-migrate-sessions
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Use `--local-dir` to put the Supabase CLI workdir somewhere else:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
lite upgrade \
|
|
67
|
+
--target local \
|
|
68
|
+
--local-dir ../my-local-supabase \
|
|
69
|
+
--force \
|
|
70
|
+
--no-migrate-sessions
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
The local target uses the Supabase CLI through `bunx supabase@2.98.1` by default. Override the executable with `LITE_SUPABASE_CLI` if needed.
|
|
74
|
+
|
|
75
|
+
Local target behavior:
|
|
76
|
+
|
|
77
|
+
- Starts a disposable-style local Supabase stack with deterministic generated config.
|
|
78
|
+
- Removes Supalite-only database config keys such as `[db].driver` and `[db].url` before starting Supabase CLI.
|
|
79
|
+
- Pins `db.major_version = 15`.
|
|
80
|
+
- Enables Studio for inspecting the upgraded local project.
|
|
81
|
+
- Disables services that are not needed for upgrade verification, including mailpit, realtime, storage, imgproxy, edge runtime, analytics/logflare/vector, and supavisor.
|
|
82
|
+
- Parses `supabase status -o json` for API URL, DB URL, anon key, service role key, and JWT secret.
|
|
83
|
+
- Applies schema/auth/data directly to the local Postgres database.
|
|
84
|
+
- Leaves the local Supabase stack running after a successful CLI upgrade.
|
|
85
|
+
|
|
86
|
+
Stop a local target manually with:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
bunx supabase@2.98.1 stop --workdir <local-dir> --no-backup
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
To rerun a local upgrade cleanly in the same workdir, stop the stack and remove Supabase CLI runtime state before running the upgrade again:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
cd <project-dir>
|
|
96
|
+
bunx supabase@2.98.1 stop --workdir . --no-backup
|
|
97
|
+
rm -rf supabase/.branches supabase/.temp
|
|
98
|
+
lite upgrade --target local --force --no-migrate-sessions
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
If the local target uses a separate directory, clean that directory instead:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
bunx supabase@2.98.1 stop --workdir <local-dir> --no-backup
|
|
105
|
+
rm -rf <local-dir>/supabase/.branches <local-dir>/supabase/.temp
|
|
106
|
+
lite upgrade --target local --local-dir <local-dir> --force --no-migrate-sessions
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
After a successful rerun, verify the database directly before relying on Studio:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
bunx supabase@2.98.1 status --workdir <local-dir-or-project-dir> -o json
|
|
113
|
+
psql '<DB URL from status>' -c '\dt public.*'
|
|
114
|
+
psql '<DB URL from status>' -c 'select * from public.<table>;'
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## What Gets Migrated
|
|
118
|
+
|
|
119
|
+
The shared upgrade runner applies statements in this order:
|
|
120
|
+
|
|
121
|
+
1. Project schema from local schema files.
|
|
122
|
+
2. `auth.users`.
|
|
123
|
+
3. `auth.identities`.
|
|
124
|
+
4. Optional hosted session rows, when session migration is enabled.
|
|
125
|
+
5. Optional hosted refresh token rows, when session migration is enabled.
|
|
126
|
+
6. User table data, in foreign-key-safe order.
|
|
127
|
+
7. Sequence resets after all migrated user data has been inserted.
|
|
128
|
+
8. Hosted auth config sync, when supported by the target.
|
|
129
|
+
|
|
130
|
+
User data migration emits inserts for application tables and resets serial or bigserial sequences after explicit migrated IDs. This avoids the common post-upgrade problem where the next insert collides with migrated primary keys.
|
|
131
|
+
|
|
132
|
+
## Session Migration
|
|
133
|
+
|
|
134
|
+
Hosted upgrades can preserve existing Supalite sessions by importing `auth.jwt_secret` as a Supabase HS256 signing key and migrating session and refresh token rows:
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
lite upgrade --migrate-sessions
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
If `auth.jwt_secret` is missing, hosted session migration fails and the CLI asks you to rerun with `--no-migrate-sessions`.
|
|
141
|
+
|
|
142
|
+
Weak JWT secrets are blocked non-interactively unless explicitly allowed:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
lite upgrade --migrate-sessions --allow-weak-jwt-secret
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use this only when preserving sessions is more important than rotating a weak development secret. If sessions are not migrated, existing tokens become invalid and users must sign in again.
|
|
149
|
+
|
|
150
|
+
Local Supabase target does not support preserving sessions yet. Run local upgrades with:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
lite upgrade --target local --no-migrate-sessions
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Auth Config
|
|
157
|
+
|
|
158
|
+
Hosted upgrades map supported Supalite auth settings to Supabase Management API auth config and apply them after schema/auth/data migration.
|
|
159
|
+
|
|
160
|
+
Local upgrades do not call Management API config endpoints. Instead, supported local Supabase CLI config values are written before the local stack starts. This currently covers settings such as API max rows, auth site URL, redirect URLs, JWT expiry, signup flags, anonymous sign-ins, minimum password length, and email confirmation behavior.
|
|
161
|
+
|
|
162
|
+
## Rehearsal and Readiness
|
|
163
|
+
|
|
164
|
+
Every non-dry-run upgrade performs:
|
|
165
|
+
|
|
166
|
+
1. Readiness checks.
|
|
167
|
+
2. An in-memory PGlite rehearsal.
|
|
168
|
+
3. The real target upgrade only if rehearsal succeeds.
|
|
169
|
+
|
|
170
|
+
`--dry-run` runs readiness and rehearsal only:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
lite upgrade --dry-run
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Rehearsal creates Supabase-compatible roles before applying grants, then exercises the generated schema/auth/data SQL against a Postgres-compatible engine.
|
|
177
|
+
|
|
178
|
+
## Known Gaps
|
|
179
|
+
|
|
180
|
+
Storage migration is not implemented. If storage is enabled, the command warns but continues with database and auth migration.
|
|
181
|
+
|
|
182
|
+
Realtime config migration is not implemented. If realtime is enabled, the command warns but continues.
|
|
183
|
+
|
|
184
|
+
Local target does not preserve sessions or JWT secret. Users must re-authenticate after local target migration.
|
|
185
|
+
|
|
186
|
+
Local Supabase is not a valid `SupabaseManagementApi` endpoint. A local CLI stack exposes API URL, DB URL, keys, and JWT secret through `supabase status`; it does not expose hosted Management API project routes like `/v1/projects/{ref}/database/query`.
|
|
187
|
+
|
|
188
|
+
Supabox is a better future target for high-fidelity hosted-flow tests, because it runs the local Supabase platform/control-plane and project lifecycle. It should augment, not replace, the faster local Supabase CLI harness.
|
|
189
|
+
|
|
190
|
+
## Testing the Upgrade Path
|
|
191
|
+
|
|
192
|
+
Fast focused tests:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
cd app
|
|
196
|
+
bun test src/cli/upgrade/*.spec.ts src/cli/commands/cloud/upgrade.cmd.spec.ts test/cli/upgrade/local-supabase-status.test.ts
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
Opt-in Docker test against local Supabase CLI:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
cd app
|
|
203
|
+
LITE_LOCAL_SUPABASE_TESTS=1 bun test test/cli/upgrade/local-supabase.test.ts
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Full default verification:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
cd app && bun test
|
|
210
|
+
bun test --recursive
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
The intended next testing layer is a fixture-based upgrade suite:
|
|
214
|
+
|
|
215
|
+
1. Copy a full Supalite fixture project to a temp directory.
|
|
216
|
+
2. Run that fixture's app/e2e tests against Supalite.
|
|
217
|
+
3. Run `lite upgrade --target local --local-dir <temp-target> --force --no-migrate-sessions`.
|
|
218
|
+
4. Point the same app/e2e tests at the upgraded Supabase API URL and anon key.
|
|
219
|
+
5. Assert the same user-visible behavior before and after upgrade.
|
|
220
|
+
|
|
221
|
+
For hosted-flow fidelity, add a separate opt-in Supabox lane later. That suite should validate the default hosted code path through a local Management API/project lifecycle rather than through the single-project Supabase CLI stack.
|