Develop schema in software projects
This tutorial builds on the foundation provided by the Get started with schema management tutorial and shows you how to do project-oriented tasks that help you manage the FSL workflow.
For an example of how to integrate these tools with GitHub Actions and GitLab CI/CD, see Supercharge your DevOps workflow with Fauna Schema Language and GitHub Actions or GitLab CI/CD |
Configure a project
Review how to Set up a project. This includes how to organize the directory structure for your FSL files and the .fauna-project configuration files.
The following project operations build on the example in that tutorial.
See the project configuration file documentation for a description of the project configuration file.
List the project environments
-
To review, list the environments you have defined in the project file:
$ cat .fauna-project schema_directory=schema default=prod [environment.prod] endpoint=cloud-example-us database=ExampleDB
This shows that one environment is defined,
prod
, which is the default environment. -
You can also use the
environment list
command to view the project environments:$ fauna environment list Available environments: * prod
Add an environment to the project
Conceptually, an environment is equivalent to a workspace or environment, such as development, test, or release. Using environments allows different organizational entities to work on the same database in their separate environments.
The following procedure uses the
environment add
command to add a
developer environment for doing development work.
-
Add a
dev
environment, selecting the developer database:$ fauna environment add ? Environment name dev ? Use the default endpoint [cloud-example-us] yes Fetching databases... done ? Select a database ❯ DevDB ExampleDB ? Make this environment default yes Saved environment dev to /home/gvh/xfer/cli/product/.fauna-project
The
dev
environment uses the same endpoint and database as theprod
environment, and the command setsdev
to the default environment. -
Notice that the project configuration file now has two environments defined:
$ cat .fauna-project schema_directory=schema default=dev [environment.prod] endpoint=cloud-example-us database=ExampleDB [environment.dev] endpoint=cloud-example-us database=DevDB
Set the default environment
If you’re working in multiple environments, you can change the project
configuration by changing the default environment using the
environment select
command.
This example changes the default environment from prod
to dev
:
-
Set the default environment to
dev
:$ fauna environment select dev Selected environment dev
-
View the configuration file to see that the default environment is now
dev
:$ cat .fauna-project schema_directory=schema default=dev [environment.prod] endpoint=cloud-example-us database=ExampleDB [environment.dev] endpoint=cloud-example-us database=DevDB
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!