Schema generation command

circle-check

Schema generation command

The .forestadmin-schema.json file is normally generated when your Rails server starts. However, in some workflows (CI/CD pipelines, pre-deployment validation), you may need to generate it without starting the server.

Usage

rails forest_admin:schema:generate

This command will:

  1. Load your Rails environment and models

  2. Execute your create_agent.rb customizations

  3. Write the .forestadmin-schema.json file

  4. Skip sending the schema to the Forest Admin API

circle-info

The schema is written to the path configured in your initializer (config.schema_path), which defaults to .forestadmin-schema.json.

Options

Option
Description

debug=true

Show stack trace on error

rails forest_admin:schema:generate debug=true

CI/CD example

You can use this command in your CI pipeline to ensure the schema is always up to date in your pull requests.

circle-exclamation

When does the schema change?

The schema needs to be regenerated when:

  • A migration is applied (new columns, tables, type changes)

  • ActiveRecord associations are modified (has_many, belongs_to, has_one...)

  • Customizations in create_agent.rb are modified (smart fields, smart actions, charts, segments, renamed fields...)

Last updated