• Start

SurrealKit

SurrealKit schema migration

SurrealKit is the official schema management and migration CLI for SurrealDB. Define your schema in .surql files and keep databases in sync across every environment.

SurrealKit is the official schema management and migration CLI for SurrealDB. You define your database schema as plain .surql files, commit them alongside your application code, and SurrealKit keeps every environment in sync with those definitions.

It has two modes:

  • Sync: immediately pushes your schema files to the connected database. Best for local development and ephemeral environments where fast iteration matters and losing data is acceptable.

  • Rollouts: generates a reviewed, phased migration manifest and applies changes in non-destructive then destructive passes, with rollback support. Best for shared, staging, and production databases.

Most teams use Sync day-to-day and switch to Rollouts when promoting changes to shared environments.

cargo binstall (recommended, no compilation required once cargo binstall is installed):

cargo binstall surrealkit

Cargo from source:

cargo install surrealkit

Docker:

docker pull ghcr.io/surrealdb/surrealkit:latest

Prebuilt binaries for Linux (x86_64 / aarch64), macOS (x86_64 / aarch64), and Windows (x86_64) are available on the GitHub releases page.

surrealkit init

This scaffolds a database/ directory with the expected layout:

database/
├── schema/ # .surql schema definition files
├── seed/ # optional seed data
├── tests/ # test suites and config
└── rollouts/ # rollout manifests (generated)

SurrealKit resolves connection details in the following order (first match wins):

  1. CLI arguments (--host, --ns, --db, --user, --pass, --auth-level)

  2. SURREALDB_* environment variables

  3. .env file in the working directory

  4. Fallback DATABASE_* environment variables

Environment variableCLI equivalentPurpose
SURREALDB_HOST--hostDatabase endpoint URL
SURREALDB_NAMESPACE--nsNamespace
SURREALDB_NAME--dbDatabase name
SURREALDB_USER--userUsername
SURREALDB_PASSWORD--passPassword
SURREALDB_AUTH_LEVEL--auth-levelroot, namespace/ns, or database/db

Example connecting via CLI flags:

surrealkit --user root --pass secret sync

Was this page helpful?