Development Server: Data and Storage
aer server starts with no records. This page describes how to keep records between runs and how to load records from an org. See Development Server for how to start the server.
Persistent storage
By default the server keeps its data in an in-memory SQLite database that is
discarded on exit. Pass --db to keep data between runs:
# SQLite file
aer server force-app/main/default --db aer.db
# PostgreSQL
aer server force-app/main/default --db postgres://aer:secret@localhost/aerA SQLite file needs no setup and suits most development. PostgreSQL runs concurrent requests in parallel, each in its own database transaction, which is useful for testing concurrent updates in code that locks records with FOR UPDATE. aer server --cluster also uses a PostgreSQL database.
The postgres:// and postgresql:// forms connect to an existing PostgreSQL
database. The schema is created with identity columns and PL/pgSQL triggers,
and the formula and SOQL functions aer needs are installed as database
functions when the database is first used. Each pooled VM opens its own
connections and transaction, so concurrent requests run in parallel rather
than serializing on one storage handle, and SELECT ... FOR UPDATE takes row
locks in the database. A lock that cannot be acquired within the lock timeout
raises a QueryException with UNABLE_TO_LOCK_ROW, the same error sfapex
raises.
A server started against an existing database does not repeat work it has already done. After a full startup aer records a fingerprint over the schema, loaded packages, and startup options. A later start with the same fingerprint attaches to the database without migrating tables or reseeding metadata. Any change to the source, packages, or flags produces a different fingerprint and runs the full startup. Upgrading aer does not require rebuilding the database.
Session tokens issued against a persistent database are stored in it, so a login survives a server restart.
Seeding a persistent database
--bootstrap-db copies tables from a SQLite file into the server’s database
before startup. The copy merges rather than replaces: rows already present in
the target are kept, a bootstrap row whose Id already exists is ignored, and
re-running the copy is a no-op. See
Bring In Setup Data for how
to build a bootstrap file.
Loading records from an org
ro --aerdb backs up an org’s records to a database that aer server --db can run against:
ro -e login.salesforce.com --aerdb backup.db
aer server --db backup.db force-appSee Using Ro With aer. ro --aerdb is in the ro 2.6 beta releases.