Migrator
dropForeignKey()
Signature
Section titled “Signature”dropForeignKey() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”dropForeignKey() is used to remove a foreign key constraint from a table in the database. This is typically done during schema changes in migrations. Only available in a migration CFC.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
table | string | yes | — | The table name to perform the operation on |
keyName | string | yes | — | the name of the key to drop |
Examples
Section titled “Examples”function up() {
// Remove a foreign key from the orders table
dropForeignKey(
table="orders",
keyName="fk_orders_customerId"
);
}
table = "orders" -> the table that has the foreign key.
keyName = "fk_orders_customerId" -> the exact name of the foreign key constraint you want to drop.