Skip to main content
The schema-engine binary provides database migration and introspection capabilities for Prisma. It can run as a JSON-RPC server over stdin/stdout or execute standalone CLI commands.

Binary Location

After building:

Interfaces

The schema engine provides two interfaces:
  1. JSON-RPC Server (default) - For interactive communication from the Prisma CLI
  2. CLI Commands - For standalone database operations

JSON-RPC Server Mode

When run without arguments, the schema engine starts as a JSON-RPC server:

Command Line Options

string[]
default:"[]"
List of paths to Prisma schema files
JSON
default:"{}"
Optional JSON string to override datasource URLs in the schema. Format:
JSON
Optional extension type configuration for TypedSQL and other extensions

JSON-RPC Methods

The schema engine exposes these JSON-RPC methods:

Migration Operations

  • createMigration - Generate a new migration from schema changes
  • applyMigrations - Apply pending migrations to the database
  • unapplyMigration - Revert the last migration
  • listMigrationDirectories - List all migrations in the migrations directory
  • markMigrationApplied - Mark a migration as applied without running it
  • markMigrationRolledBack - Mark a migration as rolled back
  • devDiagnostic - Analyze migration history for development
  • diagnoseMigrationHistory - Check migration history status
  • evaluateDataLoss - Analyze potential data loss in pending migrations

Schema Operations

  • schemaPush - Push schema changes without creating migrations
  • reset - Reset the database to a clean state
  • introspect - Generate a Prisma schema from an existing database

Database Operations

  • createDatabase - Create a new database
  • dropDatabase - Drop the database
  • ensureConnectionValidity - Test database connection

Diffing Operations

  • diff - Compare two schemas and generate a migration script

CLI Commands

Standalone commands that don’t require a running server:

create-database

Create an empty database defined in the connection string:
Output: Database 'mydb' was successfully created.

can-connect-to-database

Test if the database connection string works:
Output: Connection successful

drop-database

Drop the database:
This permanently deletes all data in the database. Use with caution.
Output: The database was successfully dropped.

Logging and Error Reporting

The schema engine outputs structured JSON logs to stderr:

Log Levels

Control logging with the RUST_LOG environment variable:

Exit Codes

exit code
Normal exit - operation completed successfully
exit code
Abnormal exit - operation failed with an error
exit code
Panic - the engine crashed due to an unrecoverable error
Non-zero exit codes are always accompanied by an ERROR-level log message on stderr.

Environment Variables

milliseconds
default:"4000"
Timeout for graceful shutdown of async tasks on SIGTERM
milliseconds
default:"200"
Deadline for blocking background tasks during shutdown
string
Configure logging verbosity (e.g., debug, schema_core=trace)

Building the Binary

1

Build with Cargo

2

Find the binary

3

Test it

Integration with Prisma CLI

The TypeScript Prisma CLI spawns the schema-engine binary and communicates via JSON-RPC:

Schema Engine Overview

Learn about the schema engine architecture

Migrations

Understand how migrations work

Introspection

Database schema introspection

Schema Core Library

Core API reference