Skip to content

Safety

Schemage distinguishes operations that may directly remove data from structural operations that only change database objects.

Operations requiring reinforced confirmation

The following operations require --force in non-interactive mode:

  • dropping tables
  • dropping columns
  • recreating tables

Table recreation is considered sensitive because it copies data into a replacement table and may omit columns that no longer exist in the desired schema.

Structural operations

The following operations do not directly delete table rows and do not require --force:

  • dropping or replacing secondary indexes
  • dropping or replacing foreign keys
  • adding columns, indexes, and foreign keys
  • renaming tables or columns
  • modifying supported column definitions

They can still affect constraints, performance, locking, or application behavior and should be reviewed in the migration plan.

Interactive behavior

Safe migration:

Apply changes? [y/N]:

A destructive migration without --force requires the complete word yes.

Using --force permits destructive operations but still keeps the interactive confirmation.

Non-interactive behavior

vendor/bin/schemage --yes

Runs without asking, but must reject destructive operations.

vendor/bin/schemage --yes --force

Runs without asking and permits destructive operations. This is the explicit automation form for CI/CD.

Production recommendation

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

Review the plan and SQL, create an appropriate backup, and schedule potentially locking operations for a suitable deployment window.