fauna schema diff

fauna schema diff [flags]

Show the diff between a database’s local, staged, or active schema.

The command runs in the context of a single database, specified using --database or --secret. If using --secret, the command runs in the database to which the secret is scoped.

By default, the command compares the database’s staged schema to schema in a local directory, specified using --dir. If no schema is staged, it compares the database’s active schema to the local schema.

Use --active to compare the database’s active schema to the local schema, regardless of whether schema is staged.

Use --staged to compare the database’s active schema to its local schema.

Flags

API
-u, --user <string>

CLI user to run the command as. You must first log in as the user using fauna login. Defaults to default. See Interactive login.

--local

Use a local Fauna container.

If not otherwise specified, this flag sets:

Pass this flag with --database and an optional --role to create a scoped key that impersonates a built-in role on a child database.

--url <string>

URL for Core HTTP API requests made by the command. Defaults to https://db.fauna.com.

--secret <string>

Secret used for authentication. Supports scoped keys. The command runs in the database to which the secret is scoped. Can’t be used with --database or --role.

--account-key <string>

Fauna account key used for authentication. If used, you must also provide a --database and an optional --role. See Account key authentication.

Can’t be used with --user or --secret. If --account-key and --user are specified, --user is ignored.

-d, --database <string>

Database, including the Region Group identifier and hierarchy, to run the command in. Supports shorthand Region Group identifiers. Separate path components using /. Examples: us/my_db, eu/parent_db/child_db, global/db. Can’t be used with --secret.

If using a local Fauna container, omit the Region Group.

-r, --role <string>

Role used to run the command. Defaults to admin. Can’t be used with --secret.

Output
--color

Enable color formatting for output. Enabled by default. Use --no-color to disable.

--json

Output results as JSON.

--quiet

Suppress all log messages except fatal errors. Output only command results. Overrides --verbosity and --verbose-component.

Config
--config <string>

Path to a CLI config file to use. If provided, must specify a profile.

-p, --profile <string>

Profile from the CLI config file. A profile is a group of CLI settings.

Debug
--verbose-component <array>

Components to emit logs for. Overrides --verbosity.

Accepts the following values:

  • argv

  • config

  • creds

  • error

  • fetch

Pass values as a space-separated list. Example: --verbose-component argv config.

--verbosity <number>

Least critical log level to emit. Accepts integers ranging from 1 (fatal) to 5 (debug). Lower values represent more critical logs. Log messages with a level greater than this value are not logged.

Options
-h, --help

Show help.

--version

Show the Fauna CLI version.

--staged

Show the diff between the active and staged schema.

--text

Show a text diff that contains line-by-line changes, including comments and whitespace.

--active

Show the diff between the active and local schema.

--fsl-directory, --dir, --directory <string>

Path to a local directory containing .fsl files for the database. Recursively scans subdirectories. Defaults to the current directory (.).

Examples

# Compare the database's staged schema to the local schema.
# If no schema is staged, compare the database's active
# schema to the local schema.
fauna schema diff \
  --database us/my_db \
  --dir /path/to/schema/dir

# Compare the active schema of the database scoped to a
# secret to the local schema.
fauna schema diff \
  --secret my-secret \
  --dir /path/to/schema/dir \
  --active

# Compare the 'us/my_db' database's active schema to the
# local schema.
fauna schema diff \
  --database us/my_db \
  --dir /path/to/schema/dir \
  --active

# Compare the 'us/my_db' database's active schema to its
# staged schema.
fauna schema diff \
  --database us/my_db \
  --dir /path/to/schema/dir \
  --staged

# Show a text diff instead of a semantic diff.
fauna schema diff \
  --database us/my_db \
  --dir /path/to/schema/dir \
  --text

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!