rent migrate diff
Use rent migrate diff before creating or applying a migration. It loads rent/schema.rsl, inspects the live database, and writes the proposed operations to standard output without changing the database.
Preview executable SQL
rent migrate diff --database-url 'postgres://app:password@localhost/blog'CREATE TABLE "public"."posts" ("author_id" bigint NOT NULL, "id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL, "title" text NOT NULL, PRIMARY KEY ("id"));
CREATE TABLE "public"."users" ("id" bigint GENERATED BY DEFAULT AS IDENTITY NOT NULL, "name" text NOT NULL, PRIMARY KEY ("id"));
ALTER TABLE "public"."posts" ADD CONSTRAINT "posts_author_id_fkey" FOREIGN KEY ("author_id") REFERENCES "public"."users" ("id");Rent renders one statement per line, exactly as it will be written to the migration file. Tables are created in
name order and server databases add foreign keys afterwards; SQLite folds them into the table definition. Use SQL output for human
review or to understand exactly what the backend will execute. Pass --format text for the classified summary that
rent migrate preflight prints instead.
Use a schema in another package
rent migrate diff --to crates/blog/rent/schema.rslThe default and custom paths both point to RSL sources. rent generate and the migration commands therefore share one source of truth.
Inspect semantic operations as JSON
rent migrate diff --database-url 'sqlite://local.db' --format json{
"operations": [
{
"CreateTable": {
"schema": "main",
"table": {
"name": "users",
"columns": [
{
"name": "id",
"sql_type": "integer",
"nullable": false,
"size": null,
"default": null,
"generated": null,
"identity": true
}
],
"primary_key": ["id"],
"indexes": [],
"foreign_keys": [],
"checks": [],
"triggers": [],
"row_level_security": false,
"policies": []
}
}
}
]
}Each operation carries the complete catalog object it creates or alters. JSON output is useful for migration policy checks, custom review tooling, or tests that should reason about an operation without parsing SQL.
Include removals explicitly
Objects that exist only in the live database are preserved by default. Include them in the plan only when removal is intentional:
rent migrate diff --drop-objectsDROP TABLE "legacy_sessions";Review every destructive operation before proceeding. rent migrate apply still requires --allow-destructive before executing it.
Restrict PostgreSQL inspection
rent migrate diff --schemas public,auditUse --schemas in databases where the application owns only a subset of PostgreSQL schemas.