Configuration

The CLI reads schemic.config.ts from your project root. Author it with defineConfig for full type-checking. schemic init scaffolds one for you.

TypeScript
import { defineConfig } from "@schemic/core/config";

export default defineConfig({
  db: {
    url: process.env.SURREAL_URL ?? "ws://localhost:8000",
    namespace: "app",
    database: "app",
    username: process.env.SURREAL_USER,
    password: process.env.SURREAL_PASS,
    authLevel: "root",
  },
});

Top-level options

OptionTypeDefaultDescription
dbconnectionThe database connection. Required.
schemastring./database/schemaDirectory (or file) of schema modules, loaded recursively.
migrationsstring./database/migrationsDirectory of .surql migrations and their meta/ snapshot.
migrationsTablestring_migrationsTable that records applied migrations.
seedstring./database/seed.tsSeed script run by schemic seed.
checkobjectOverrides for the schemic check replay (see below).

Connection (db)

FieldTypeDescription
urlstringEndpoint, e.g. ws://localhost:8000 or http://localhost:8000.
namespacestringTarget namespace.
databasestringTarget database.
usernamestringAuth username.
passwordstringAuth password.
authLevel"root" | "namespace" | "database"Level to sign in at. Default root.

Resolution order

Each connection field resolves in this order, first match wins:

  1. A CLI flag (--url, --namespace, …).
  2. The value in schemic.config.ts.
  3. An environment variable: SURREAL_URL, SURREAL_NAMESPACE, SURREAL_DATABASE, SURREAL_USER, SURREAL_PASS.

This lets you commit a config with env-backed secrets and override the target per command.

Check replay (check)

schemic check replays migrations in a throwaway engine. Configure which engine with check.engine:

engineBehaviour
"auto" (default)Use the local surreal CLI for an ephemeral in-memory instance if present; otherwise fall back to the server.
"binary"Require the local surreal CLI; error if missing.
"remote"Always use a server, creating and dropping throwaway scratch databases.
{ backend, ... }Run in-process via the optional @surrealdb/node package.
TypeScript
// Always replay against a scratch server, never production:
check: { engine: "remote", db: { url: "ws://localhost:8000", namespace: "scratch" } },

// Or fully in-process (npm i -D @surrealdb/node):
check: { engine: { backend: "memory" } },

Where to go next