supabee 0.3.7 → 0.3.9
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 +340 -340
- package/dist/commands/data.js +52 -20
- package/dist/commands/data.js.map +1 -1
- package/dist/commands/db-reset.js +125 -86
- package/dist/commands/db-reset.js.map +1 -1
- package/dist/commands/init.js +4 -4
- package/dist/commands/migration.js +9 -9
- package/dist/commands/migration.js.map +1 -1
- package/dist/commands/schema.js +6 -3
- package/dist/commands/schema.js.map +1 -1
- package/dist/index.js +54 -54
- package/dist/lib/mixed-migration-splitter.d.ts +3 -1
- package/dist/lib/mixed-migration-splitter.js +1 -0
- package/dist/lib/mixed-migration-splitter.js.map +1 -1
- package/dist/lib/reset-summary.d.ts +28 -0
- package/dist/lib/reset-summary.js +139 -0
- package/dist/lib/reset-summary.js.map +1 -0
- package/dist/lib/subprocess.js +7 -7
- package/dist/lib/ui.d.ts +4 -0
- package/dist/lib/ui.js +12 -0
- package/dist/lib/ui.js.map +1 -1
- package/package.json +54 -54
- package/supabee.config.example.json +29 -29
package/README.md
CHANGED
|
@@ -1,194 +1,194 @@
|
|
|
1
|
-
# Supabee
|
|
2
|
-
|
|
3
|
-
[](https://github.com/kaihochak/supabee/actions/workflows/ci.yml)
|
|
4
|
-
[](https://www.npmjs.com/package/supabee)
|
|
5
|
-
[](./LICENSE)
|
|
6
|
-
|
|
7
|
-
Orchestrate local Supabase schema/data workflows: split giant SQL dumps into organized files, and apply post-seed migrations in a production-like order.
|
|
8
|
-
|
|
9
|
-
## Why?
|
|
10
|
-
|
|
11
|
-
Supabase workflows often end up with two pain points:
|
|
12
|
-
|
|
13
|
-
1. **One huge dump file** (`supabase db dump` / `--data-only`) that's painful to review, edit, or selectively seed from.
|
|
14
|
-
2. **Local reset/start ordering** (migrations → seeds) that can diverge from production deploys (new migrations applied onto an already-populated database).
|
|
15
|
-
|
|
16
|
-
`supabee` addresses both:
|
|
17
|
-
|
|
18
|
-
- **Split + validate dumps:** split schema and data dumps into focused files (by category / by table), then reconstruct and validate round-trip (PR-friendly diffs, easier navigation, and smaller merge conflicts).
|
|
19
|
-
- **Defer post-seed migrations:** temporarily move newer migrations out of the way for `supabase db reset` / `supabase start`, then restore + reapply them after seeds load.
|
|
20
|
-
|
|
21
|
-
### Use cases
|
|
22
|
-
|
|
23
|
-
- **Seed data you can control:** keep per-table seed files and point `[db.seed].sql_paths` at only the ones you want.
|
|
24
|
-
- **Schema as docs / source of truth:** keep schema readable in-repo (tables, functions, RLS, permissions, etc.).
|
|
25
|
-
- **Mimic production locally:** catch “works on reset” vs “works on deploy” issues by applying post-seed migrations after data exists.
|
|
26
|
-
- **One-liners with validation:** `sync schema` / `sync data` run dump → split → reconstruct → validate.
|
|
27
|
-
|
|
28
|
-
### Repo hygiene (recommended)
|
|
29
|
-
|
|
30
|
-
Commit split outputs (for example `supabase/schemas/split/**` and `supabase/seeds/split/**`), and ignore large generated artifacts in your repo:
|
|
31
|
-
|
|
32
|
-
```gitignore
|
|
33
|
-
# raw dumps (generated from prod; optional to keep locally)
|
|
34
|
-
supabase/schemas/prod-schemas.sql
|
|
35
|
-
supabase/seeds/prod-data.sql
|
|
36
|
-
|
|
37
|
-
# reconstructed outputs (validation artifacts)
|
|
38
|
-
supabase/schemas/reconstructed-schemas.sql
|
|
39
|
-
supabase/seeds/reconstructed-data.sql
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Prerequisites
|
|
43
|
-
|
|
44
|
-
- [Node.js](https://nodejs.org/) >= 18
|
|
45
|
-
- [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) installed and authenticated
|
|
46
|
-
|
|
47
|
-
## Install
|
|
48
|
-
|
|
49
|
-
Global install (recommended):
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
npm i -g supabee
|
|
53
|
-
pnpm add -g supabee
|
|
54
|
-
bun add -g supabee
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
One-off run without global install:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
npx supabee --help
|
|
61
|
-
pnpm dlx supabee --help
|
|
62
|
-
bunx supabee --help
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
Project-local install (optional):
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
npm install --save-dev supabee
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Setup
|
|
72
|
-
|
|
73
|
-
### 1. Initialize config
|
|
74
|
-
|
|
75
|
-
Run `init` to generate `supabee.config.json` (if it doesn't exist) and update `supabase/config.toml` seed paths:
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
supabee init
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Review the generated `supabee.config.json` and adjust paths/limits for your project.
|
|
82
|
-
|
|
83
|
-
### 2. Link your Supabase project
|
|
84
|
-
|
|
85
|
-
If you haven't already, link your local repo to your Supabase project. This is required before you can dump schema or data:
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
supabase link
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
You'll be prompted for your project ref and database password. See the [Supabase CLI docs](https://supabase.com/docs/reference/cli/supabase-link) for details.
|
|
92
|
-
|
|
93
|
-
### 3. Run the primary workflows
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
supabee sync schema
|
|
97
|
-
supabee sync data
|
|
98
|
-
supabee db reset [cutoff_timestamp]
|
|
99
|
-
supabee start [cutoff_timestamp]
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
`sync` commands run end-to-end:
|
|
103
|
-
|
|
104
|
-
- schema: `supabase db dump` -> split -> reconstruct -> validate
|
|
105
|
-
- data: `supabase db dump --data-only` -> split -> reconstruct -> validate
|
|
106
|
-
|
|
107
|
-
### Selective seeding example (optional)
|
|
108
|
-
|
|
109
|
-
By default, `supabee init` configures `supabase/config.toml` to load all split seed files (for example `./seeds/split/*.sql`).
|
|
110
|
-
To seed only a subset, replace `[db.seed].sql_paths` with an explicit ordered list (keep `001_setup.sql` and `999_cleanup.sql`; add the generated `*_sequences.sql` file if you need sequence values):
|
|
111
|
-
|
|
112
|
-
```toml
|
|
113
|
-
[db.seed]
|
|
114
|
-
sql_paths = [
|
|
115
|
-
"./seeds/split/001_setup.sql",
|
|
116
|
-
"./seeds/split/002_public_users.sql",
|
|
117
|
-
"./seeds/split/003_public_projects.sql",
|
|
118
|
-
"./seeds/split/999_cleanup.sql",
|
|
119
|
-
]
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Commands
|
|
123
|
-
|
|
124
|
-
### `init`
|
|
125
|
-
|
|
126
|
-
Creates `supabee.config.json` if missing, then updates `supabase/config.toml` `[db.seed].sql_paths` so Supabase knows where to find your split seed files.
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
supabee init
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
### `schema`
|
|
133
|
-
|
|
134
|
-
Processes an existing schema dump into categorized folders:
|
|
135
|
-
|
|
136
|
-
```
|
|
137
|
-
supabase/schemas/split/
|
|
138
|
-
├── 00_extensions/
|
|
139
|
-
├── 01_setup/
|
|
140
|
-
├── 02_types/
|
|
141
|
-
├── 03_functions/
|
|
142
|
-
├── 04_tables/
|
|
143
|
-
├── 05_views/
|
|
144
|
-
├── 06_constraints/
|
|
145
|
-
├── 07_indexes/
|
|
146
|
-
├── 08_foreign_keys/
|
|
147
|
-
├── 09_rls/
|
|
148
|
-
├── 10_permissions/
|
|
149
|
-
├── 11_ownership/
|
|
150
|
-
└── 12_others/
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
```bash
|
|
154
|
-
# Full chain (split → reconstruct → validate)
|
|
155
|
-
supabee schema
|
|
156
|
-
|
|
157
|
-
# Individual steps
|
|
158
|
-
supabee schema split
|
|
159
|
-
supabee schema reconstruct
|
|
160
|
-
supabee schema validate
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### `data`
|
|
164
|
-
|
|
165
|
-
Processes an existing data dump into per-table files with configurable row/statement limits:
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
# Full chain (split → reconstruct → validate)
|
|
169
|
-
supabee data
|
|
170
|
-
|
|
171
|
-
# Individual steps
|
|
172
|
-
supabee data split
|
|
173
|
-
supabee data reconstruct
|
|
174
|
-
supabee data validate
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
### `sync schema`
|
|
178
|
-
|
|
179
|
-
Dumps schema from the linked Supabase project, then runs full schema processing:
|
|
180
|
-
|
|
1
|
+
# Supabee
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kaihochak/supabee/actions/workflows/ci.yml)
|
|
4
|
+
[](https://www.npmjs.com/package/supabee)
|
|
5
|
+
[](./LICENSE)
|
|
6
|
+
|
|
7
|
+
Orchestrate local Supabase schema/data workflows: split giant SQL dumps into organized files, and apply post-seed migrations in a production-like order.
|
|
8
|
+
|
|
9
|
+
## Why?
|
|
10
|
+
|
|
11
|
+
Supabase workflows often end up with two pain points:
|
|
12
|
+
|
|
13
|
+
1. **One huge dump file** (`supabase db dump` / `--data-only`) that's painful to review, edit, or selectively seed from.
|
|
14
|
+
2. **Local reset/start ordering** (migrations → seeds) that can diverge from production deploys (new migrations applied onto an already-populated database).
|
|
15
|
+
|
|
16
|
+
`supabee` addresses both:
|
|
17
|
+
|
|
18
|
+
- **Split + validate dumps:** split schema and data dumps into focused files (by category / by table), then reconstruct and validate round-trip (PR-friendly diffs, easier navigation, and smaller merge conflicts).
|
|
19
|
+
- **Defer post-seed migrations:** temporarily move newer migrations out of the way for `supabase db reset` / `supabase start`, then restore + reapply them after seeds load.
|
|
20
|
+
|
|
21
|
+
### Use cases
|
|
22
|
+
|
|
23
|
+
- **Seed data you can control:** keep per-table seed files and point `[db.seed].sql_paths` at only the ones you want.
|
|
24
|
+
- **Schema as docs / source of truth:** keep schema readable in-repo (tables, functions, RLS, permissions, etc.).
|
|
25
|
+
- **Mimic production locally:** catch “works on reset” vs “works on deploy” issues by applying post-seed migrations after data exists.
|
|
26
|
+
- **One-liners with validation:** `sync schema` / `sync data` run dump → split → reconstruct → validate.
|
|
27
|
+
|
|
28
|
+
### Repo hygiene (recommended)
|
|
29
|
+
|
|
30
|
+
Commit split outputs (for example `supabase/schemas/split/**` and `supabase/seeds/split/**`), and ignore large generated artifacts in your repo:
|
|
31
|
+
|
|
32
|
+
```gitignore
|
|
33
|
+
# raw dumps (generated from prod; optional to keep locally)
|
|
34
|
+
supabase/schemas/prod-schemas.sql
|
|
35
|
+
supabase/seeds/prod-data.sql
|
|
36
|
+
|
|
37
|
+
# reconstructed outputs (validation artifacts)
|
|
38
|
+
supabase/schemas/reconstructed-schemas.sql
|
|
39
|
+
supabase/seeds/reconstructed-data.sql
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Prerequisites
|
|
43
|
+
|
|
44
|
+
- [Node.js](https://nodejs.org/) >= 18
|
|
45
|
+
- [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) installed and authenticated
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
Global install (recommended):
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npm i -g supabee
|
|
53
|
+
pnpm add -g supabee
|
|
54
|
+
bun add -g supabee
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
One-off run without global install:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx supabee --help
|
|
61
|
+
pnpm dlx supabee --help
|
|
62
|
+
bunx supabee --help
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Project-local install (optional):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
npm install --save-dev supabee
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Setup
|
|
72
|
+
|
|
73
|
+
### 1. Initialize config
|
|
74
|
+
|
|
75
|
+
Run `init` to generate `supabee.config.json` (if it doesn't exist) and update `supabase/config.toml` seed paths:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
supabee init
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Review the generated `supabee.config.json` and adjust paths/limits for your project.
|
|
82
|
+
|
|
83
|
+
### 2. Link your Supabase project
|
|
84
|
+
|
|
85
|
+
If you haven't already, link your local repo to your Supabase project. This is required before you can dump schema or data:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
supabase link
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
You'll be prompted for your project ref and database password. See the [Supabase CLI docs](https://supabase.com/docs/reference/cli/supabase-link) for details.
|
|
92
|
+
|
|
93
|
+
### 3. Run the primary workflows
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
supabee sync schema
|
|
97
|
+
supabee sync data
|
|
98
|
+
supabee db reset [cutoff_timestamp]
|
|
99
|
+
supabee start [cutoff_timestamp]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
`sync` commands run end-to-end:
|
|
103
|
+
|
|
104
|
+
- schema: `supabase db dump` -> split -> reconstruct -> validate
|
|
105
|
+
- data: `supabase db dump --data-only` -> split -> reconstruct -> validate
|
|
106
|
+
|
|
107
|
+
### Selective seeding example (optional)
|
|
108
|
+
|
|
109
|
+
By default, `supabee init` configures `supabase/config.toml` to load all split seed files (for example `./seeds/split/*.sql`).
|
|
110
|
+
To seed only a subset, replace `[db.seed].sql_paths` with an explicit ordered list (keep `001_setup.sql` and `999_cleanup.sql`; add the generated `*_sequences.sql` file if you need sequence values):
|
|
111
|
+
|
|
112
|
+
```toml
|
|
113
|
+
[db.seed]
|
|
114
|
+
sql_paths = [
|
|
115
|
+
"./seeds/split/001_setup.sql",
|
|
116
|
+
"./seeds/split/002_public_users.sql",
|
|
117
|
+
"./seeds/split/003_public_projects.sql",
|
|
118
|
+
"./seeds/split/999_cleanup.sql",
|
|
119
|
+
]
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Commands
|
|
123
|
+
|
|
124
|
+
### `init`
|
|
125
|
+
|
|
126
|
+
Creates `supabee.config.json` if missing, then updates `supabase/config.toml` `[db.seed].sql_paths` so Supabase knows where to find your split seed files.
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
supabee init
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### `schema`
|
|
133
|
+
|
|
134
|
+
Processes an existing schema dump into categorized folders:
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
supabase/schemas/split/
|
|
138
|
+
├── 00_extensions/
|
|
139
|
+
├── 01_setup/
|
|
140
|
+
├── 02_types/
|
|
141
|
+
├── 03_functions/
|
|
142
|
+
├── 04_tables/
|
|
143
|
+
├── 05_views/
|
|
144
|
+
├── 06_constraints/
|
|
145
|
+
├── 07_indexes/
|
|
146
|
+
├── 08_foreign_keys/
|
|
147
|
+
├── 09_rls/
|
|
148
|
+
├── 10_permissions/
|
|
149
|
+
├── 11_ownership/
|
|
150
|
+
└── 12_others/
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# Full chain (split → reconstruct → validate)
|
|
155
|
+
supabee schema
|
|
156
|
+
|
|
157
|
+
# Individual steps
|
|
158
|
+
supabee schema split
|
|
159
|
+
supabee schema reconstruct
|
|
160
|
+
supabee schema validate
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### `data`
|
|
164
|
+
|
|
165
|
+
Processes an existing data dump into per-table files with configurable row/statement limits:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Full chain (split → reconstruct → validate)
|
|
169
|
+
supabee data
|
|
170
|
+
|
|
171
|
+
# Individual steps
|
|
172
|
+
supabee data split
|
|
173
|
+
supabee data reconstruct
|
|
174
|
+
supabee data validate
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### `sync schema`
|
|
178
|
+
|
|
179
|
+
Dumps schema from the linked Supabase project, then runs full schema processing:
|
|
180
|
+
|
|
181
181
|
```bash
|
|
182
182
|
supabee sync schema
|
|
183
183
|
supabee sync schema --input supabase/schemas/prod-schemas.sql --output supabase/schemas/split
|
|
184
184
|
supabee sync schema --backup
|
|
185
185
|
supabee sync schema --force
|
|
186
186
|
```
|
|
187
|
-
|
|
188
|
-
### `sync data`
|
|
189
|
-
|
|
190
|
-
Dumps data (`--data-only`) from the linked Supabase project, then runs full data processing:
|
|
191
|
-
|
|
187
|
+
|
|
188
|
+
### `sync data`
|
|
189
|
+
|
|
190
|
+
Dumps data (`--data-only`) from the linked Supabase project, then runs full data processing:
|
|
191
|
+
|
|
192
192
|
```bash
|
|
193
193
|
supabee sync data
|
|
194
194
|
supabee sync data --input supabase/seeds/prod-data.sql --output supabase/seeds/split
|
|
@@ -196,7 +196,7 @@ supabee sync data --backup
|
|
|
196
196
|
supabee sync data --no-backup
|
|
197
197
|
supabee sync data --force
|
|
198
198
|
```
|
|
199
|
-
|
|
199
|
+
|
|
200
200
|
### `db reset`
|
|
201
201
|
|
|
202
202
|
Defers post-seed migrations newer than the cutoff timestamp, runs `supabase db reset`, restores deferred migrations, then reapplies them.
|
|
@@ -207,13 +207,13 @@ Mixed migrations at/before cutoff run in compatibility mode by default (warning
|
|
|
207
207
|
When post-cutoff mixed files are detected, `supabee` can prompt to auto-split them inline during `db reset`/`start`.
|
|
208
208
|
Before applying, `supabee` prints a full before/after migration filename rewrite plan and asks for confirmation.
|
|
209
209
|
Auto-split is blocked if a mixed migration version is already applied on the linked remote project.
|
|
210
|
-
|
|
211
|
-
If `[cutoff_timestamp]` is omitted, `supabee` auto-detects it from `supabase migration list --linked` by taking the latest migration version that exists in both local and remote (works even when remote has gaps).
|
|
210
|
+
|
|
211
|
+
If `[cutoff_timestamp]` is omitted, `supabee` auto-detects it from `supabase migration list --linked` by taking the latest migration version that exists in both local and remote (works even when remote has gaps).
|
|
212
212
|
When linked lookup succeeds, `supabee` stores the value in `supabee.config.json` as `postSeedCutoff` (or `postSeedCutoffByEnv.<env>` when `--env` is set).
|
|
213
213
|
If linked lookup fails (for example in CI), it falls back to `postSeedCutoffByEnv.<env>` when `--env` is set, otherwise `postSeedCutoff`.
|
|
214
214
|
If not linked, `supabee` runs `supabase link` and retries once.
|
|
215
|
-
|
|
216
|
-
```bash
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
217
|
# default re-apply mode: supabase migration up
|
|
218
218
|
supabee db reset 20260309180959
|
|
219
219
|
supabee db reset
|
|
@@ -225,19 +225,19 @@ supabee db reset 20260309180959 --psql
|
|
|
225
225
|
# strict mixed policy
|
|
226
226
|
supabee db reset --strict-mixed
|
|
227
227
|
```
|
|
228
|
-
|
|
228
|
+
|
|
229
229
|
### `start`
|
|
230
230
|
|
|
231
231
|
Defers post-seed migrations newer than the cutoff timestamp, runs `supabase start`, restores deferred migrations, then reapplies them.
|
|
232
232
|
For historical data-migration files, `supabee` temporarily swaps the file body to a no-op during the run, then restores the original SQL file content.
|
|
233
233
|
When post-cutoff mixed files are detected, `supabee` can prompt to auto-split them inline before continuing.
|
|
234
|
-
|
|
235
|
-
If `[cutoff_timestamp]` is omitted, `supabee` auto-detects it from `supabase migration list --linked` the same way as `db reset`.
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
# explicit cutoff
|
|
239
|
-
supabee start 20260309180959
|
|
240
|
-
|
|
234
|
+
|
|
235
|
+
If `[cutoff_timestamp]` is omitted, `supabee` auto-detects it from `supabase migration list --linked` the same way as `db reset`.
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
# explicit cutoff
|
|
239
|
+
supabee start 20260309180959
|
|
240
|
+
|
|
241
241
|
# auto cutoff from linked migration alignment
|
|
242
242
|
supabee start
|
|
243
243
|
|
|
@@ -314,40 +314,40 @@ supabee migration split-mixed --apply
|
|
|
314
314
|
```
|
|
315
315
|
|
|
316
316
|
### Supabase passthrough
|
|
317
|
-
|
|
318
|
-
Unknown commands are forwarded to Supabase CLI:
|
|
319
|
-
|
|
320
|
-
```bash
|
|
321
|
-
supabee migration up # forwards to: supabase migration up
|
|
322
|
-
supabee db dump # forwards to: supabase db dump
|
|
323
|
-
```
|
|
324
|
-
|
|
325
|
-
### Overriding paths
|
|
326
|
-
|
|
327
|
-
`schema`, `data`, and `sync` commands accept `--input` and `--output` flags:
|
|
328
|
-
|
|
329
|
-
```bash
|
|
330
|
-
supabee schema split --input path/to/schema.sql --output path/to/split
|
|
331
|
-
supabee schema split --input path/to/schema.sql --output path/to/split --backup
|
|
332
|
-
supabee data split --input path/to/data.sql --output path/to/split
|
|
333
|
-
supabee data split --input path/to/data.sql --output path/to/split --no-backup
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
By default, split operations replace existing output in-place (while preserving configured `keepFiles`) without creating a backup folder.
|
|
337
|
-
Use `--backup` to keep a timestamped backup before replacement.
|
|
338
|
-
|
|
339
|
-
## Configuration
|
|
340
|
-
|
|
341
|
-
`supabee` reads `supabee.config.json` from your project root.
|
|
342
|
-
|
|
343
|
-
**Precedence:** CLI flags > config file > built-in defaults.
|
|
344
|
-
|
|
345
|
-
If the config file is missing, built-in defaults are used. Run `supabee init` to generate one.
|
|
346
|
-
|
|
347
|
-
Legacy support: `supabase-splitter.config.json` is still recognized, but `supabee.config.json` is preferred.
|
|
348
|
-
|
|
349
|
-
### Full config reference
|
|
350
|
-
|
|
317
|
+
|
|
318
|
+
Unknown commands are forwarded to Supabase CLI:
|
|
319
|
+
|
|
320
|
+
```bash
|
|
321
|
+
supabee migration up # forwards to: supabase migration up
|
|
322
|
+
supabee db dump # forwards to: supabase db dump
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
### Overriding paths
|
|
326
|
+
|
|
327
|
+
`schema`, `data`, and `sync` commands accept `--input` and `--output` flags:
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
supabee schema split --input path/to/schema.sql --output path/to/split
|
|
331
|
+
supabee schema split --input path/to/schema.sql --output path/to/split --backup
|
|
332
|
+
supabee data split --input path/to/data.sql --output path/to/split
|
|
333
|
+
supabee data split --input path/to/data.sql --output path/to/split --no-backup
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
By default, split operations replace existing output in-place (while preserving configured `keepFiles`) without creating a backup folder.
|
|
337
|
+
Use `--backup` to keep a timestamped backup before replacement.
|
|
338
|
+
|
|
339
|
+
## Configuration
|
|
340
|
+
|
|
341
|
+
`supabee` reads `supabee.config.json` from your project root.
|
|
342
|
+
|
|
343
|
+
**Precedence:** CLI flags > config file > built-in defaults.
|
|
344
|
+
|
|
345
|
+
If the config file is missing, built-in defaults are used. Run `supabee init` to generate one.
|
|
346
|
+
|
|
347
|
+
Legacy support: `supabase-splitter.config.json` is still recognized, but `supabee.config.json` is preferred.
|
|
348
|
+
|
|
349
|
+
### Full config reference
|
|
350
|
+
|
|
351
351
|
```json
|
|
352
352
|
{
|
|
353
353
|
"postSeedCutoff": "",
|
|
@@ -358,45 +358,45 @@ Legacy support: `supabase-splitter.config.json` is still recognized, but `supabe
|
|
|
358
358
|
"dataMigrationMarker": "supabee:data-migration",
|
|
359
359
|
"schemaMigrationMarker": "supabee:schema-migration",
|
|
360
360
|
"schema": {
|
|
361
|
-
"input": "supabase/schemas/prod-schemas.sql",
|
|
362
|
-
"output": "supabase/schemas/split",
|
|
363
|
-
"reconstructed": "supabase/schemas/reconstructed-schemas.sql",
|
|
364
|
-
"backup": false,
|
|
365
|
-
"keepFiles": []
|
|
366
|
-
},
|
|
367
|
-
"data": {
|
|
368
|
-
"input": "supabase/seeds/prod-data.sql",
|
|
369
|
-
"output": "supabase/seeds/split",
|
|
370
|
-
"reconstructed": "supabase/seeds/reconstructed-data.sql",
|
|
371
|
-
"backup": false,
|
|
372
|
-
"maxLinesPerFile": 2000,
|
|
373
|
-
"maxStatementsPerFile": 20,
|
|
374
|
-
"maxRowsPerInsert": 200,
|
|
375
|
-
"tableRules": {},
|
|
376
|
-
"keepFiles": [],
|
|
377
|
-
"ignoreInReconstruct": []
|
|
378
|
-
},
|
|
379
|
-
"init": {
|
|
380
|
-
"seedSqlPaths": ["./seeds/split/*.sql"]
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
| Key | Description |
|
|
386
|
-
|-----|-------------|
|
|
387
|
-
| `schema.input` | Path to your schema dump file |
|
|
388
|
-
| `schema.output` | Directory for split schema files |
|
|
389
|
-
| `schema.reconstructed` | Path for the reconstructed schema (used in validation) |
|
|
390
|
-
| `schema.backup` | Whether split should create backup folder before replacing output (default: `false`) |
|
|
391
|
-
| `schema.keepFiles` | Files in the split dir to preserve across re-splits |
|
|
392
|
-
| `data.input` | Path to your data dump file |
|
|
393
|
-
| `data.output` | Directory for split data files |
|
|
394
|
-
| `data.reconstructed` | Path for the reconstructed data (used in validation) |
|
|
395
|
-
| `data.backup` | Whether split should create backup folder before replacing output (default: `false`) |
|
|
396
|
-
| `data.maxLinesPerFile` | Max lines per split file (default: 2000) |
|
|
397
|
-
| `data.maxStatementsPerFile` | Max INSERT statements per file (default: 20) |
|
|
398
|
-
| `data.maxRowsPerInsert` | Max rows per INSERT statement (default: 200) |
|
|
399
|
-
| `data.tableRules` | Per-table overrides (see below) |
|
|
361
|
+
"input": "supabase/schemas/prod-schemas.sql",
|
|
362
|
+
"output": "supabase/schemas/split",
|
|
363
|
+
"reconstructed": "supabase/schemas/reconstructed-schemas.sql",
|
|
364
|
+
"backup": false,
|
|
365
|
+
"keepFiles": []
|
|
366
|
+
},
|
|
367
|
+
"data": {
|
|
368
|
+
"input": "supabase/seeds/prod-data.sql",
|
|
369
|
+
"output": "supabase/seeds/split",
|
|
370
|
+
"reconstructed": "supabase/seeds/reconstructed-data.sql",
|
|
371
|
+
"backup": false,
|
|
372
|
+
"maxLinesPerFile": 2000,
|
|
373
|
+
"maxStatementsPerFile": 20,
|
|
374
|
+
"maxRowsPerInsert": 200,
|
|
375
|
+
"tableRules": {},
|
|
376
|
+
"keepFiles": [],
|
|
377
|
+
"ignoreInReconstruct": []
|
|
378
|
+
},
|
|
379
|
+
"init": {
|
|
380
|
+
"seedSqlPaths": ["./seeds/split/*.sql"]
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
| Key | Description |
|
|
386
|
+
|-----|-------------|
|
|
387
|
+
| `schema.input` | Path to your schema dump file |
|
|
388
|
+
| `schema.output` | Directory for split schema files |
|
|
389
|
+
| `schema.reconstructed` | Path for the reconstructed schema (used in validation) |
|
|
390
|
+
| `schema.backup` | Whether split should create backup folder before replacing output (default: `false`) |
|
|
391
|
+
| `schema.keepFiles` | Files in the split dir to preserve across re-splits |
|
|
392
|
+
| `data.input` | Path to your data dump file |
|
|
393
|
+
| `data.output` | Directory for split data files |
|
|
394
|
+
| `data.reconstructed` | Path for the reconstructed data (used in validation) |
|
|
395
|
+
| `data.backup` | Whether split should create backup folder before replacing output (default: `false`) |
|
|
396
|
+
| `data.maxLinesPerFile` | Max lines per split file (default: 2000) |
|
|
397
|
+
| `data.maxStatementsPerFile` | Max INSERT statements per file (default: 20) |
|
|
398
|
+
| `data.maxRowsPerInsert` | Max rows per INSERT statement (default: 200) |
|
|
399
|
+
| `data.tableRules` | Per-table overrides (see below) |
|
|
400
400
|
| `data.keepFiles` | Files in the split dir to preserve across re-splits |
|
|
401
401
|
| `data.ignoreInReconstruct` | Files to skip during reconstruction |
|
|
402
402
|
| `init.seedSqlPaths` | Paths written to `supabase/config.toml` `[db.seed].sql_paths` |
|
|
@@ -404,30 +404,30 @@ Legacy support: `supabase-splitter.config.json` is still recognized, but `supabe
|
|
|
404
404
|
| `postSeedCutoffByEnv` | Optional per-environment fallback cutoff map (for example `staging`, `production`) |
|
|
405
405
|
| `dataMigrationMarker` | Optional override marker for data migrations (default: `supabee:data-migration`) |
|
|
406
406
|
| `schemaMigrationMarker` | Optional override marker for schema migrations (default: `supabee:schema-migration`) |
|
|
407
|
-
|
|
408
|
-
### Table-specific rules
|
|
409
|
-
|
|
410
|
-
Override limits or skip specific tables:
|
|
411
|
-
|
|
412
|
-
```json
|
|
413
|
-
{
|
|
414
|
-
"data": {
|
|
415
|
-
"tableRules": {
|
|
416
|
-
"public.cities": {
|
|
417
|
-
"maxLinesPerFile": 800,
|
|
418
|
-
"maxStatementsPerFile": 8,
|
|
419
|
-
"maxRowsPerInsert": 80
|
|
420
|
-
},
|
|
421
|
-
"public.audit_logs": {
|
|
422
|
-
"skip": true
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
## Flags
|
|
430
|
-
|
|
407
|
+
|
|
408
|
+
### Table-specific rules
|
|
409
|
+
|
|
410
|
+
Override limits or skip specific tables:
|
|
411
|
+
|
|
412
|
+
```json
|
|
413
|
+
{
|
|
414
|
+
"data": {
|
|
415
|
+
"tableRules": {
|
|
416
|
+
"public.cities": {
|
|
417
|
+
"maxLinesPerFile": 800,
|
|
418
|
+
"maxStatementsPerFile": 8,
|
|
419
|
+
"maxRowsPerInsert": 80
|
|
420
|
+
},
|
|
421
|
+
"public.audit_logs": {
|
|
422
|
+
"skip": true
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
```
|
|
428
|
+
|
|
429
|
+
## Flags
|
|
430
|
+
|
|
431
431
|
`schema`, `data`, `sync schema`, and `sync data` support:
|
|
432
432
|
|
|
433
433
|
- `--input`: source SQL file
|
|
@@ -437,7 +437,7 @@ Override limits or skip specific tables:
|
|
|
437
437
|
- `--force` (sync commands only): skip linked migration alignment preflight
|
|
438
438
|
|
|
439
439
|
For `validate`, you can pass reconstructed path either as `--output <path>` or as the second positional argument.
|
|
440
|
-
|
|
440
|
+
|
|
441
441
|
`db reset` supports:
|
|
442
442
|
|
|
443
443
|
- `--psql`: apply deferred migrations via `psql` instead of `supabase migration up`
|
|
@@ -458,26 +458,26 @@ For `validate`, you can pass reconstructed path either as `--output <path>` or a
|
|
|
458
458
|
|
|
459
459
|
- `--env <name>`: include environment fallback lookup
|
|
460
460
|
- `--json`: print machine-readable output
|
|
461
|
-
|
|
462
|
-
## Deep dive: why `supabee db reset` and `supabee start`
|
|
463
|
-
|
|
464
|
-
The short version is in the **Why?** section above. These commands matter most when local replay order diverges from how production data actually evolved:
|
|
465
|
-
|
|
466
|
-
1. Seed files may be shaped for pre-migration schema.
|
|
467
|
-
2. Some migrations intentionally mutate/seed production data for traceability (for example RBAC rows).
|
|
468
|
-
3. Local `migrations -> seed` replay can fail even when production worked on already-populated data.
|
|
469
|
-
|
|
470
|
-
By deferring post-seed migrations and applying them after seed load, `supabee` better matches this production-style path.
|
|
471
|
-
|
|
472
|
-
## Migration + Seed Duplication Caveat
|
|
473
|
-
|
|
474
|
-
If the same logical data mutation exists in both migration SQL and seed files, local replay can become order-dependent and brittle.
|
|
475
|
-
|
|
476
|
-
Typical symptoms:
|
|
477
|
-
- enum/value already exists errors,
|
|
478
|
-
- duplicate key or constraint violations,
|
|
479
|
-
- reset/start-only failures that don’t appear on incremental production deploys.
|
|
480
|
-
|
|
461
|
+
|
|
462
|
+
## Deep dive: why `supabee db reset` and `supabee start`
|
|
463
|
+
|
|
464
|
+
The short version is in the **Why?** section above. These commands matter most when local replay order diverges from how production data actually evolved:
|
|
465
|
+
|
|
466
|
+
1. Seed files may be shaped for pre-migration schema.
|
|
467
|
+
2. Some migrations intentionally mutate/seed production data for traceability (for example RBAC rows).
|
|
468
|
+
3. Local `migrations -> seed` replay can fail even when production worked on already-populated data.
|
|
469
|
+
|
|
470
|
+
By deferring post-seed migrations and applying them after seed load, `supabee` better matches this production-style path.
|
|
471
|
+
|
|
472
|
+
## Migration + Seed Duplication Caveat
|
|
473
|
+
|
|
474
|
+
If the same logical data mutation exists in both migration SQL and seed files, local replay can become order-dependent and brittle.
|
|
475
|
+
|
|
476
|
+
Typical symptoms:
|
|
477
|
+
- enum/value already exists errors,
|
|
478
|
+
- duplicate key or constraint violations,
|
|
479
|
+
- reset/start-only failures that don’t appear on incremental production deploys.
|
|
480
|
+
|
|
481
481
|
Recommended approach:
|
|
482
482
|
|
|
483
483
|
1. Keep schema structure changes in migrations.
|
|
@@ -486,16 +486,16 @@ Recommended approach:
|
|
|
486
486
|
4. Use `supabee migration audit` to review classification and `supabee migration mark` if you want explicit marker comments in files.
|
|
487
487
|
5. Keep data migrations free of schema DDL (`CREATE`/`ALTER`/`DROP ...`); mixed files are blocked and must be split.
|
|
488
488
|
6. Make migration-time data mutations idempotent (`IF NOT EXISTS`, `ON CONFLICT DO NOTHING`, guarded updates).
|
|
489
|
-
|
|
490
|
-
## Help
|
|
491
|
-
|
|
492
|
-
```bash
|
|
493
|
-
supabee --help
|
|
494
|
-
supabee init --help
|
|
495
|
-
supabee sync --help
|
|
496
|
-
supabee sync schema --help
|
|
497
|
-
supabee sync data --help
|
|
498
|
-
supabee schema --help
|
|
489
|
+
|
|
490
|
+
## Help
|
|
491
|
+
|
|
492
|
+
```bash
|
|
493
|
+
supabee --help
|
|
494
|
+
supabee init --help
|
|
495
|
+
supabee sync --help
|
|
496
|
+
supabee sync schema --help
|
|
497
|
+
supabee sync data --help
|
|
498
|
+
supabee schema --help
|
|
499
499
|
supabee data --help
|
|
500
500
|
supabee start --help
|
|
501
501
|
supabee db --help
|
|
@@ -505,17 +505,17 @@ supabee migration audit --help
|
|
|
505
505
|
supabee migration mark --help
|
|
506
506
|
supabee migration unmark --help
|
|
507
507
|
```
|
|
508
|
-
|
|
509
|
-
Legacy CLI alias is still available: `supabase-splitter --help`.
|
|
510
|
-
|
|
511
|
-
## Development
|
|
512
|
-
|
|
513
|
-
```bash
|
|
514
|
-
npm install
|
|
515
|
-
npm run typecheck
|
|
516
|
-
npm run build
|
|
517
|
-
npm run test
|
|
518
|
-
npm run pack:check
|
|
519
|
-
```
|
|
520
|
-
|
|
521
|
-
RC gate checklist: `docs/rc-checklist.md`
|
|
508
|
+
|
|
509
|
+
Legacy CLI alias is still available: `supabase-splitter --help`.
|
|
510
|
+
|
|
511
|
+
## Development
|
|
512
|
+
|
|
513
|
+
```bash
|
|
514
|
+
npm install
|
|
515
|
+
npm run typecheck
|
|
516
|
+
npm run build
|
|
517
|
+
npm run test
|
|
518
|
+
npm run pack:check
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
RC gate checklist: `docs/rc-checklist.md`
|