cmd migrate firebase - nself-org/cli GitHub Wiki
Generate nSelf migration artifacts from a Firebase Firestore and Auth export.
nself migrate firebase --export-dir <path> [flags]
nself migrate firebase converts a Firebase Firestore JSON export into the migration artifacts needed to run the same data on nSelf: a migration.sql schema file, a hasura-metadata.yaml file, an optional auth-import.sql for migrating Auth users, and a MIGRATION_SUMMARY.md guide.
No live Firebase connection is required. The command operates entirely on locally exported JSON files, so it is safe to run in air-gapped or CI environments.
The migration process does not apply any changes to your nSelf project automatically. All generated files are written to the output directory for review before you apply them.
- Export your Firestore data:
firebase firestore:export --format json ./firebase-export
- Optionally export your Auth users:
firebase auth:export --format json ./firebase-export/auth-users.json
- Run the migration command:
nself migrate firebase --export-dir ./firebase-export
- Review the generated files in
<export-dir>/nself-migration/. - Apply the schema and metadata to your nSelf project.
| Flag | Default | Description |
|---|---|---|
--export-dir |
— | Directory produced by firebase firestore:export. Required.
|
--auth-export |
"" |
Path to Firebase Auth JSON export (optional) |
--output-dir |
<export-dir>/nself-migration |
Directory for generated artifacts |
--project-name |
firebase_import |
Project name used in generated SQL schema names and file prefixes |
| File | Contents |
|---|---|
migration.sql |
CREATE TABLE statements with RLS scaffolding for each inferred collection |
hasura-metadata.yaml |
Hasura table tracking and permissions scaffold |
auth-import.sql |
INSERT statements for Auth users (only when --auth-export is provided) |
MIGRATION_SUMMARY.md |
Step-by-step guide for applying the artifacts to nSelf |
# Basic: export dir only
nself migrate firebase --export-dir ./firebase-export
# With Auth users
nself migrate firebase \
--export-dir ./firebase-export \
--auth-export ./firebase-export/auth-users.json
# Custom output directory and project name
nself migrate firebase \
--export-dir ./firebase-export \
--output-dir ./nself-migration \
--project-name myappAfter reviewing the generated files:
# Apply the schema SQL to your nSelf Postgres instance
nself db migrate --file ./nself-migration/migration.sql
# Import Hasura metadata (via Hasura console or CLI)
hasura metadata apply --directory ./nself-migration/hasura-metadata.yaml
# Import auth users (if generated)
nself exec psql < ./nself-migration/auth-import.sqlSee MIGRATION_SUMMARY.md in the output directory for the full step-by-step instructions specific to your export.
- Collection naming follows Firestore conventions. Nested sub-collections become separate tables with a
_parent_idforeign key. - Firestore types are mapped to Postgres types on a best-effort basis. Review
migration.sqlbefore applying. - Firestore Security Rules are not converted. Apply your Hasura row-level security policies manually.
- cmd-migrate — v0.9 to v1 project migration
- cmd-migrate-supabase — migrate from Supabase
- cmd-db — run schema migrations on a live project