Skip to content

Rollback

Schemage stores executed operations and rollback SQL in its migration history infrastructure.

Roll back the latest batch:

vendor/bin/schemage --rollback

Preview rollback SQL:

vendor/bin/schemage --rollback --dry-run

Rollback availability depends on whether the original operation has enough metadata for a safe inverse.

Operation Typical inverse
Add column Drop column
Modify column Restore the previous definition
Rename column Rename it back
Rename table Rename it back
Add index Drop index
Drop index Recreate the previous index when metadata was recorded
Add foreign key Drop foreign key
Drop foreign key Recreate the previous foreign key when metadata was recorded

Dropping a table or column cannot automatically restore deleted row data.