Skip to content

SQL Generation

Schemage can print SQL without applying migrations.

Export pending migration SQL

vendor/bin/schemage --sql

This introspects the current database, calculates the diff, applies driver-specific operation planning, and prints SQL for the pending migration.

Save it to a file:

vendor/bin/schemage --sql > migration.sql

Use --force when the planned migration contains operations that require it:

vendor/bin/schemage --sql --force > migration.sql

Export the complete schema

vendor/bin/schemage --schema-sql

This generates SQL directly from the desired schema without calculating a diff against the current database.

Save it to a file:

vendor/bin/schemage --schema-sql > install.sql

Schemage writes SQL to standard output so shell redirection and pipelines work naturally.