Check out v4 of the Fauna CLI

v4 of the Fauna CLI is now in beta.

The new version introduces enhancements to the developer experience, including an improved authentication workflow. To get started, check out the CLI v4 quick start.

fauna schema diff

Prints the diff between local, staged, or active schema.

Syntax

fauna schema diff [--active] [--[no-]color ] [--dir <value>]
  [--endpoint <value>] [--environment <value>] [--help]
  [--secret <value>] [--staged] [--text] [--timeout <value>]
  [--url <value>]

Description

fauna schema diff prints the diff between local and remote schema. See Examples.

Arguments

None

Options

Option Description

--active

Show the diff between the local and remote active schema.

--[no-]color

Enables or disables color formatting for the output. Color formatting is enabled by default if the terminal supports it (determined using chalk/supports-color). Use --no-color to disable.

--dir

A local directory of .fsl files to compare. Defaults to the directory specified in .fauna-project.

--endpoint

Fauna server endpoint.

--environment

Environment to use from .fauna-project.

--help

Help for schema diff command.

--secret

Authentication secret. Overrides the secret in .fauna-shell.

Use a scoped key to interact with a child database using a parent database’s admin key.

For example, with a parent database’s admin key secret of fn123, you can access a child database by appending the child database name and role: fn123:childDB:admin.

--staged

Show the diff between the remote active and remote staged schema.

--text

Display the text diff instead of the semantic diff.

--timeout

Connection timeout in milliseconds.

--url

Database URL. Overrides the url in .fauna-shell.

Examples

Compare local to staged schema

fauna schema diff

This compares the project’s local schema to the database’s remote staged schema:

Connected to endpoint: cloud-us
Differences from the remote, staged schema to the local schema:
* Modifying collection `Customer` at collections.fsl:1:1:
  * Indexes:
  + add index `byEmail`

If the database has no staged schema, the command compares the database’s local schema to the remote active schema instead:

Connected to endpoint: cloud-us
Differences from the remote schema to the local schema:
* Modifying collection `Customer` at collections.fsl:1:1 (previously defined at main.fsl:4:1):
  * Indexes:
  + add index `sortedByName`

Compare local to active schema

fauna schema diff --active
Connected to endpoint: cloud-us
Differences from the remote, active schema to the local schema:
* Modifying collection `Customer` at collections.fsl:4:1:
  * Indexes:
  + add index `byEmail`

Compare active to staged schema

fauna schema diff --staged
Connected to endpoint: cloud-us
Differences from the remote, active schema to the remote, staged schema:
* Modifying collection `Customer` at collections.fsl:4:1:
  * Indexes:
  + add index `byEmail`

Display text diff instead of semantic diff

Use --text to show a textual difference instead of a semantic one:

fauna schema diff --text
Connected to endpoint: cloud-us
Differences from the remote, staged schema to the local schema:
collections.fsl
@ line 1 to 7
  collection Customer {
    email: String
+
+   index byEmail {
+     terms [.email]
+   }
  }

Specify a schema directory

Use --dir to specify a schema directory containing local .fsl schema files:

fauna schema diff --dir schemas/myschema

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!