laizy sync
Sync your local schema with the database — preview changes, review migration plans, and apply updates safely.
laizy sync
The sync command compares your local .laizy schema file against the current database state and applies the necessary changes. It shows a migration plan with impact analysis before executing, giving you full visibility into what will change.
Usage
pnpm laizy sync # Interactive sync with confirmations
pnpm laizy sync --dry-run # Preview changes without applying
pnpm laizy sync --force # Skip confirmation promptsFlags
| Flag | Description |
|---|---|
--dry-run | Show the migration plan without executing any changes |
--force | Skip all confirmation prompts (useful for CI/CD) |
How It Works
When you run laizy sync, the command:
- Reads your local schema from the path configured in
~/.laizyrc(default:laizy/schema.laizy) - Fetches the current remote schema from the Laizy API for your linked project
- Computes a diff identifying models to create, update, or delete
- Generates a migration plan with impact classifications (safe, warning, destructive)
- Enriches with content impact showing how many entries are affected per model
- Asks for confirmation if the plan contains warning or destructive changes
- Executes the migration and shows updated model status
Example Output
No changes needed
Laizy CMS Schema Sync
Found schema file: ./laizy/schema.laizy
Parsed 3 models
Analysis complete
Schema is already up to date!Creating new models
Laizy CMS Schema Sync
Found schema file: ./laizy/schema.laizy
Parsed 3 models
Analysis complete
Migration Plan:
Operation Model Impact Description
──────────── ──────── ────── ───────────
create_model BlogPost safe Create new content model "BlogPost" with 4 fields (no existing content)
create_model Author safe Create new content model "Author" with 3 fields (no existing content)
Executing migration...
Migration completed successfully
Updated Models:
Model Fields Entries Last Updated
──────── ────── ─────── ────────────
BlogPost 4 0 just now
Author 3 0 just nowDestructive changes
When the plan includes destructive changes, the CLI shows explicit warnings:
Migration Plan:
Operation Model Impact Description
──────────── ──────── ────── ───────────
update_model BlogPost warning Update model "BlogPost" (1 field changes) (15 entries affected)
delete_model OldPage destructive Delete content model "OldPage" and all associated content (3 entries affected)
DESTRUCTIVE: Deleting model "OldPage" will permanently remove all content data (3 content entries will be affected)
? Are you absolutely sure you want to continue? This cannot be undone. (y/N)Dry Run Mode
Use --dry-run to preview the migration plan without making changes:
pnpm laizy sync --dry-runThis runs the full analysis pipeline -- parsing, diffing, planning, and content impact analysis -- but stops before execution. Use this to review changes before committing to them.
Migration Plan:
Operation Model Impact Description
──────────── ──────── ────── ───────────
create_model Product safe Create new content model "Product" with 4 fields
Dry run complete - no changes madeAlways run --dry-run before applying schema changes in production. It is the safest way to verify that your schema modifications will produce the expected migration plan.
Force Mode
Use --force to skip all confirmation prompts:
pnpm laizy sync --forceThis is designed for CI/CD pipelines and automated scripts where interactive prompts are not possible. The migration executes immediately regardless of impact level.
The --force flag bypasses all safety confirmations, including for destructive changes that permanently delete data. Only use this when you have already reviewed the migration plan via --dry-run.
Project Context
The sync command requires a linked project. It reads the project ID from .laizy/project.json, which is created by laizy init or laizy link.
If no project is linked, the command will fail with:
Error: No project linked to this directory
Run laizy link to connect to a projectPost-Sync Status
After a successful migration, the CLI displays updated model status:
Updated Models:
Model Fields Entries Last Updated
──────── ────── ─────── ────────────
BlogPost 4 15 just now
Author 3 8 just now
Product 5 0 just now
View in dashboard: https://laizycms.com/dashboard/content-modelError Handling
Schema parsing errors
If your schema file has syntax errors, the CLI reports them with line numbers:
Schema parsing failed
Error: Line 5: Expected ":" after field nameAuthentication errors
If your API token is invalid or expired:
Analysis failed
Error: unauthorized
This might be an authentication issue.
Try running laizy init to update your credentials.Migration execution errors
If a migration operation fails, the CLI reports the error and exits with a non-zero status code. Operations that completed before the failure are not rolled back.
Next Steps
After syncing your schema:
- Generate the client: Run
pnpm laizy generateto create a TypeScript client - Create content: Use
pnpm laizy content createto add entries - Check status: Run
pnpm laizy statusto see your current schema state
- Generate Command -- Create a TypeScript client from your synced schema
- Migrations -- Deep dive into how migration plans work
- Content Commands -- Create and list content from the CLI