.reylo.yaml
The keys of Reylo's project file
Configure Reylo in a .reylo.yaml (or .reylo.yml) file beside package.json. Every key is optional:
# the dev database Reylo reads your schema from (the default)
direct_url: ${DATABASE_URL}
# the .env files Reylo reads (the default)
env: [.env.local, .env]
# a parameter whose type cannot be inferred is an error (the default)
allow_untyped_params: false
# a Postgres array column holds one dimension (the default)
allow_nested_arrays: false
# a comment naming each query's file, for your database's monitoring (the default)
sqlcommenter: true
# the directory of Reylo's files: schema.sql, the migrations and its cache (the default)
dir: reyloReylo uses the nearest package.json at or above the directory it runs in. One in your home directory doesn't count.
direct_url
The dev database Reylo reads your schema from. It defaults to DATABASE_URL, and its scheme names the dialect:
# or postgresql://
DATABASE_URL=postgres://localhost:5432/app# or mariadb://
DATABASE_URL=mysql://root@localhost:3306/app# the path starts at package.json
DATABASE_URL=sqlite:./app.db# or clickhouse+https://, the URL of the HTTP interface
DATABASE_URL=clickhouse+http://default@localhost:8123/appPoint it at a direct connection, not a pooler. A pooler in transaction mode, such as PgBouncer, can fail to describe a query. You can interpolate other variables from your environment to construct a connection string.
# the default is ${DATABASE_URL}
direct_url: postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:5432/appA variable can fall back, as in a shell, when it is unset or empty:
direct_url: ${BUILD_DATABASE_URL:-${DATABASE_URL}}To keep a password out of every file, use $(…). It runs a command, such as a password manager's, and puts what it prints in its place. Reylo runs it once per editor session or build, and again when a login is refused.
# or $(aws rds generate-db-auth-token …) for a short-lived token
direct_url: postgres://app:$(op read op://dev/db/password)@db:5432/appA type check or build reads this database, while .run() uses the client you pass in. Apply your migrations first in CI and on your host. To type-check a script against production directly:
DATABASE_URL="$PRODUCTION_URL" node --import reylo/register report.tsThe type check reads TLS settings from the URL in direct_url:
# postgres: encrypted, no certificate check
DATABASE_URL=postgres://…/app?sslmode=require
# postgres: the certificate and host checked
DATABASE_URL=postgres://…/app?sslmode=verify-full
# mysql: encrypted, no certificate check
DATABASE_URL=mysql://…/app?ssl-mode=REQUIRED
# mysql: the certificate and host checked
DATABASE_URL=mysql://…/app?ssl-mode=VERIFY_IDENTITYThe defaults, and the other settings each reads:
- With no setting, a Postgres connection is encrypted where the server offers it, and a MySQL connection isn't.
- Postgres also reads libpq's
sslrootcert,sslcert,sslkeyandchannel_binding, and node-postgres'sssl=true. - MySQL also reads mysql2's
sslJSON setting and Prisma'ssslaccept=strict. - A certificate is also checked against the certificates
NODE_EXTRA_CA_CERTSnames, as Node checks it.
env
The .env files Reylo reads, relative to .reylo.yaml. The first file that sets a variable wins, and the environment wins over every file.
# the default is [.env.local, .env]
env: [.env.development, .env]Reylo reads them as dotenv does. A # outside quotes starts a comment, so quote a value that holds one:
# or mysql://… or sqlite:./path/to/your.db, etc
DATABASE_URL="postgres://app:pa#ss@localhost:5432/app" # the dev databaseallow_untyped_params
Whether a parameter whose type cannot be inferred may stay unknown.
By default it's an error that says to cast it.
# the default is false
allow_untyped_params: trueallow_nested_arrays
Whether a Postgres array column may hold nested arrays.
Postgres doesn't track an array's dimensions. By default Reylo types an array column as one-dimensional, and .run() throws on a deeper value. With this set, the column is a NestedArray<T> of any depth.
# the default is false
allow_nested_arrays: truesqlcommenter
Reylo appends a sqlcommenter comment naming each query's file, so tools like Datadog and PlanetScale can group queries by source. Set sqlcommenter: false to omit it:
# the default is true
sqlcommenter: falseOn SQLite, the comment opens the query instead. The query's .sql property leaves the comment out. By default, Postgres receives:
select id, name, email from where id = $1::int /*file='queries%2Fget_user.sql'*/dir
The directory beside .reylo.yaml that holds Reylo's files. You commit its migrations, and its .cache/ keeps itself out of git.
# the default is reylo
dir: dbshadow_url
The server where migrations build their shadow databases, for a database whose own server refuses create database:
# the default is the database's own server
shadow_url: ${SHADOW_URL}