Skip to content

Migrator

dropReference()

dropReference() — returns void

Available in: migration Category: Migration Functions

Drop a foreign key constraint from the database, using the reference name that was used to create it Only available in a migration CFC

NameTypeRequiredDefaultDescription
tablestringyes—The table name to perform the operation on
referenceNamestringno—the name of the reference to drop
columnNamestringno—Alias for referenceName (consistent with the modern migrator surface — columnName / columnNames are accepted alongside the legacy form).
columnNamesstringno—Plural alias for referenceName. When both columnName and columnNames are supplied, columnNames wins.
// 1. Drop the foreign key from comments.postId back to posts.id
// Removes the constraint named FK_comments_posts
dropReference(table="comments", referenceName="post");

// 2. Drop a foreign key from order_items back to orders
// Removes the constraint named FK_order_items_orders
dropReference(table="order_items", referenceName="order");

// 3. Use dropReference in the down() of a migration that added a reference in up()
// In your migration CFC:
//
// public void function up() {
//     addReference(table="comments", referenceName="post");
// }
//
// public void function down() {
//     dropReference(table="comments", referenceName="post");
// }