Documentation
¶
Overview ¶
Package firebase implements the Firebase → nSelf migration scaffold.
It reads a Firestore JSON export (produced by `firebase firestore:export`), infers a relational schema from the document structure, and generates:
- A Drizzle-compatible SQL migration file
- A Hasura metadata YAML (table tracking + permissions scaffold)
- An optional Firebase Auth → nSelf auth user import script
- A human-readable next-steps summary
The command intentionally does NOT call any Firebase HTTP API at runtime. The operator runs `firebase firestore:export --format json <outdir>` first, then points `nself migrate firebase --export-dir <outdir>` at the output. This avoids requiring a live Firebase project during migration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionInfo ¶
type CollectionInfo struct {
// Name is the Firestore collection name.
Name string
// TableName is the SQL-safe table name derived from Name.
TableName string
// Columns holds the inferred column definitions.
Columns []ColumnDef
// SampleCount is the number of documents sampled during inference.
SampleCount int
}
CollectionInfo holds the inferred schema for a single Firestore collection.
type ColumnDef ¶
type ColumnDef struct {
// Name is the SQL-safe column name.
Name string
// SQLType is the inferred PostgreSQL type.
SQLType string
// Nullable indicates whether the column may be NULL (field missing in some docs).
Nullable bool
}
ColumnDef describes a single inferred column.
type Options ¶
type Options struct {
// ExportDir is the directory produced by `firebase firestore:export`.
// It must contain at least one *.json file with Firestore document data.
ExportDir string
// AuthExportFile is an optional path to a Firebase Auth users JSON export
// (produced by `firebase auth:export --format json <file>`).
// When set, an auth-import.sql file is generated alongside the schema migration.
AuthExportFile string
// OutputDir is the directory where migration artifacts are written.
// Defaults to <ExportDir>/nself-migration if empty.
OutputDir string
// ProjectName is used to name the generated migration files and schema.
// Defaults to "firebase_import" if empty.
ProjectName string
// DryRun, when true, prints the generated SQL to stdout instead of writing files.
DryRun bool
}
Options holds the user-supplied parameters for a Firebase migration run.
type Result ¶
type Result struct {
// SchemaSQL is the path to the generated SQL migration file.
SchemaSQL string
// HasuraYAML is the path to the generated Hasura metadata YAML.
HasuraYAML string
// AuthImportSQL is the path to the auth user import script (may be empty).
AuthImportSQL string
// Summary is the path to the human-readable next-steps summary.
Summary string
// Tables is the list of inferred table names.
Tables []string
}
Result holds the paths of all generated migration artifacts.