Skip to main content
In legacy agents, the datasource was tied to a single ORM (Sequelize, Mongoose, ActiveRecord, Mongoid). The new agent introduces an explicit datasource layer that supports multiple databases and APIs in the same agent, and decouples the connection from the framework.

API cheatsheet

Pick datasource-sql or datasource-mongo if you want Forest to introspect the database directly. Pick datasource-sequelize, datasource-mongoose, or datasource-active-record if you want to reuse your existing ORM models (recommended when your application already defines them).

Before (Node.js, forest-express-sequelize)

After (Node.js, reusing Sequelize models)

After (Node.js, direct SQL connection)

If you don’t want to reuse your ORM models, connect directly to the database. Forest introspects the schema automatically.

Before (Ruby, forest-rails with ActiveRecord)

After (Ruby, ActiveRecord)

Run rails generate forest_admin_rails:install to scaffold the two configuration files.

Multi-datasource

The biggest payoff of migrating: the new agent can connect to multiple data sources at once.
Cross-datasource relationships are first-class. See Relationships.

Configuration changes

Including or excluding collections

In v1, you’d manually filter the models passed in. In v2:
These options only hide collections: with datasource-sql, the whole schema is still read at boot. To avoid that, cache the introspection.

Match the names your layout already uses

Your layout refers to collections and fields by name, so the new agent must expose the same names as the old one. A mismatch raises no error: the old configuration just stops applying. Whether names change depends on what each agent reads: So a Sequelize project that keeps datasource-sequelize usually has nothing to rename, while one moving to datasource-sql does. Restore the old names where they differ:

Prove the match before you deploy

You can check names without a running environment, by diffing the new agent’s schema against the legacy one:
1

Capture the introspection once

2

Generate the new schema without a database

Build models from that file, with no database connection:
Use the same rename and customizations as your real agent.
3

Diff against the legacy schema

Compare the collection and field names in .forestadmin-schema.v2.json with the legacy .forestadmin-schema.json, adding rename and renameField entries until they match.
Once the names match, your existing layout applies to the new agent.

Validate the migration

After swapping the datasource:
1

Start the new agent

Run on a different port from the legacy agent (e.g. 3001).
2

Check schema generation

On first start in development, the agent writes a .forestadmin-schema.json file. Confirm every collection you expect is listed.
3

Smoke-test the API

Hit http://localhost:3001/forest, which should return Forest metadata.
4

Point a test environment at the new agent

Update the agent URL in your Forest test environment. Browse collections. Every collection should appear with the same fields.
5

Continue with customizations

Once data flows correctly, move on to migrating Smart Actions, Smart Fields, and the rest.

Common issues

Some legacy agents auto-converted snake_case to camelCase. The new agent preserves database column names by default. Use the rename option or the field-rename customization API to align names.
Foreign keys defined in the database are detected automatically. Relationships defined only in your ORM models (belongsTo, hasMany) are detected when you use the ORM-backed datasources (datasource-sequelize, datasource-mongoose, datasource-active-record). Relationships that exist only in code paths the agent doesn’t see won’t be detected. Declare them explicitly with addManyToOneRelation, addOneToManyRelation, etc.
Verify that DATABASE_URL is set on the agent server, that the user has read permissions, and that SSL is configured if your database requires it. For SQL datasources, check sslMode.

Next step

Migrate Smart Actions

Convert each Smart Action to the new addAction API.