cmd migrate supabase - nself-org/cli GitHub Wiki
Pull schema, data, auth users, and storage buckets from a Supabase project and generate nSelf migration artifacts.
nself migrate supabase --project-ref <ref> --supabase-key <key> [flags]
nself migrate supabase connects to a live Supabase project via the PostgREST and Admin APIs, pulls your public schema, auth users, and storage buckets, then generates three migration artifacts: a Drizzle-compatible SQL migration file, a Hasura metadata YAML, and a shell script to import your auth users.
Unlike nself migrate firebase, this command requires live access to your Supabase project. Use NSELF_SUPABASE_SKIP=1 to skip live connectivity in CI environments.
| Flag | Default | Description |
|---|---|---|
--project-ref |
— | Supabase project reference ID (the ID in your project URL). Required. |
--supabase-key |
— |
service_role key from Supabase > Project Settings > API. Required.
|
--out |
. |
Output directory for generated files |
- Connect to Supabase and pull public schema (tables, columns, RLS policies where accessible)
- Pull auth users via the Supabase Admin API
- Pull storage buckets via the Supabase Storage API
- Generate a Drizzle-compatible SQL migration file
- Generate Hasura metadata YAML
- Generate an auth user import script
- Write all files to the output directory
| File | Contents |
|---|---|
supabase-migration.sql |
CREATE TABLE statements compatible with Drizzle and nSelf's Postgres instance |
hasura-metadata.yaml |
Hasura table tracking and permissions scaffold |
import-auth-users.sh |
Shell script to import Supabase auth users into nSelf Auth |
| Variable | Description |
|---|---|
NSELF_SUPABASE_SKIP |
Set to 1 to skip live Supabase connectivity (CI mode) |
# Basic migration
nself migrate supabase \
--project-ref abcdefghijkl \
--supabase-key eyJhbGci...
# Write artifacts to a named output directory
nself migrate supabase \
--project-ref abcdefghijkl \
--supabase-key eyJhbGci... \
--out ./migration
# CI environment: skip live connectivity
NSELF_SUPABASE_SKIP=1 nself migrate supabase \
--project-ref ci-project-ref \
--supabase-key ci-service-key-
Project ref: the alphanumeric ID in your Supabase project URL:
https://app.supabase.com/project/<ref> -
Service role key: Supabase Dashboard > Project Settings > API >
service_role(keep this secret)
After the command completes, apply the generated files to your nSelf project:
# Apply the schema migration
nself db migrate --file ./migration/supabase-migration.sql
# Apply Hasura metadata (via Hasura console or CLI)
hasura metadata apply --directory ./migration/hasura-metadata.yaml
# Import auth users
bash ./migration/import-auth-users.sh- Only the
publicschema is pulled. Tables in other schemas require manual migration. - Supabase-specific features (Edge Functions, Realtime subscriptions) are not converted.
- RLS policies are pulled where the
service_rolekey has access; reviewsupabase-migration.sqlbefore applying.
- cmd-migrate — v0.9 to v1 project migration
- cmd-migrate-firebase — migrate from Firebase
- cmd-db — run schema migrations on a live project