Skip to main content
Geni can be configured using environment variables to customize its behavior for different database environments and migration workflows.

Required Variables

DATABASE_URL
string
required
The database connection string used for migrations. This is the only required environment variable.See Database URLs for format examples for each supported database.
If DATABASE_URL is not set, Geni will exit with an error: “missing DATABASE_URL env variable”

Optional Variables

Migration Configuration

DATABASE_MIGRATIONS_FOLDER
string
default:"./migrations"
Specifies the directory where Geni looks for migration files.
# Migrations are read from ./migrations
geni up
DATABASE_MIGRATIONS_TABLE
string
default:"schema_migrations"
Name of the table used to track applied migrations.
# Uses schema_migrations table
geni up

Schema Dumping

DATABASE_SCHEMA_FILE
string
default:"schema.sql"
Name of the schema file that Geni creates after running migrations.The schema file provides a complete SQL representation of your database structure, useful for version control and documentation.
# Creates schema.sql
geni up
DATABASE_NO_DUMP_SCHEMA
boolean
default:"false"
Disables automatic schema dumping after migrations.Set to "true" to prevent Geni from creating a schema file. Useful in environments where schema dumping is not needed or not supported.
geni up
Schema dumping requires additional tools for some databases:
  • MySQL: mysqldump binary
  • MariaDB: mariadb-dump binary
  • PostgreSQL, SQLite, LibSQL: No additional tools required

Connection Configuration

DATABASE_WAIT_TIMEOUT
number
default:"30"
Time in seconds to wait for the database to become available before timing out.Useful when running migrations in environments where the database might take time to start (e.g., Docker containers, CI/CD pipelines).
geni up
DATABASE_TOKEN
string
Authentication token for LibSQL and Turso databases.Only required when connecting to LibSQL instances or Turso that require authentication. If not specified, Geni attempts to connect without authentication.
DATABASE_URL="https://your-db.turso.io" \
DATABASE_TOKEN="your-auth-token" \
geni up
For Turso databases, retrieve your authentication token using the Turso CLI or from the Turso dashboard.

Complete Example

Here’s a complete example with all environment variables configured:
DATABASE_URL="postgres://user:pass@localhost:5432/myapp?sslmode=disable" \
DATABASE_MIGRATIONS_FOLDER="./db/migrations" \
DATABASE_MIGRATIONS_TABLE="_migrations" \
DATABASE_SCHEMA_FILE="db/schema.sql" \
DATABASE_WAIT_TIMEOUT="60" \
geni up

Using .env Files

You can use .env files to manage environment variables:
.env
DATABASE_URL=postgres://user:pass@localhost:5432/myapp?sslmode=disable
DATABASE_MIGRATIONS_FOLDER=./db/migrations
DATABASE_MIGRATIONS_TABLE=_migrations
DATABASE_SCHEMA_FILE=db/schema.sql
DATABASE_WAIT_TIMEOUT=60
Then load the file before running Geni:
source .env && geni up
Never commit .env files containing sensitive credentials to version control. Add .env to your .gitignore file.

CI/CD Usage

In CI/CD environments, set DATABASE_URL as a secret environment variable:
name: Run Migrations
on: [push]

jobs:
  migrate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: emilpriver/geni@main
        with:
          database_url: ${{ secrets.DATABASE_URL }}
          migrations_folder: "./migrations"
          wait_timeout: "30"

Build docs developers (and LLMs) love