schema abandon

Abandons a staged schema change.

Syntax

fauna schema abandon [-y | --no-input] [--[no-]color ]
  [--dir <value>] [--endpoint <value>] [--environment <value>]
  [--help] [--secret <value>] [--timeout <value>] [--url <value>]

Description

fauna schema abandon abandons a staged schema change.

You can abandon a staged schema change at any time, including a change with the ready status. This is useful when you want to discard changes that are no longer needed or failed during staging.

No staged schema changes

If a database has no staged schema, the command returns an error:

›   Error: There is no staged schema to abandon

To stage schema, use the schema push command. See Run a staged schema change.

Arguments

None

Options

Option Description

-y, --no-input

Abandon the staged schema change without confirmation input.

--[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. Defaults to the directory specified in .fauna-project.

--endpoint

Fauna server endpoint.

--environment

Environment to use from .fauna-project.

--help

Help for the command.

--secret

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

--timeout

Connection timeout in milliseconds.

--url

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

Examples

Basic example

To abandon a staged schema change, regardless of its status:

fauna schema abandon

By default, the command returns a semantic diff containing the staged schema changes and requires a confirmation to abandon the changes:

Connected to endpoint: cloud-us
* Modifying collection `Customer` at collections.fsl:3:1:
  * Indexes:
  + add index `byEmail`


? Abandon these changes? (y/N)

Abandon a staged schema change without input

Use the --no-input option or its -y alias to abandon a staged schema change without prompting for confirmation or displaying a diff. This is useful for using the command programmatically, such as in a CI/CD workflow.

fauna schema abandon --no-input

Or:

fauna schema abandon -y

Run a staged schema change

You use the schema abandon command as part of a staged schema change.

A staged schema change lets you change one or more collection schema without index downtime due to index builds.

To run a staged schema change:

  1. Make the desired changes to .fsl files in your schema directory.

    You can’t use a staged schema change to delete or rename schema. Instead, delete or rename the schema in a separate unstaged schema change.

  2. Use fauna schema push to stage the schema changes. fauna schema push stages schema changes by default:

    fauna schema push

    This allows Fauna to build indexes for the updated schema before applying the schema to the database.

    A database can have one staged schema change at a time. You can update staged schema using fauna schema push.

    When a database has staged schema, any access or updates done using FQL’s schema commands on related system collections interact with the staged schema, not the database’s active schema.

    For example, when schema changes are staged, Collection.all() returns Collection documents for the staged collection schema, not the database’s Collection documents.

    If a database has staged schema, you can’t edit the database’s active schema using FQL, the Dashboard, or an unstaged schema change. You must first abandon the staged schema change.

  3. Use fauna schema status to check the status of the staged schema:

    fauna schema status

    Possible statuses:

    Staged status Description

    pending

    Changes are being processed. New indexes are still being built.

    ready

    All indexes have been built. Changes are ready to commit.

    failed

    There was an error during the staging process.

  4. When the status is ready, use fauna schema commit to apply the staged schema to the database:

    fauna schema commit

    You can only commit staged schema with a status of ready.

    If you no longer wish to apply the staged schema or if the status is failed, use fauna schema abandon to unstage the schema:

    fauna schema abandon

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!