Migrator
down()
Signature
Section titled “Signature”down() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”down() defines the steps to revert a database migration. It’s executed when rolling back a migration, typically to undo the changes applied by the corresponding up() function. Only available in a migration CFC
Examples
Section titled “Examples”function down() {
transaction {
try {
// your code goes here
dropTable('myTable');
} catch (any e) {
local.exception = e;
}
if (StructKeyExists(local, "exception")) {
transaction action="rollback";
throw(errorCode="1", detail=local.exception.detail, message=local.exception.message, type="any");
} else {
transaction action="commit";
}
}
}