Skip to content

Migrator

updateRecord()

updateRecord() — returns void

Available in: migration Category: Migration Functions

Allows you to update an existing record in a database table directly from within a migration CFC. This function is particularly useful when you need to modify data as part of a schema migration, such as setting default values, correcting legacy data, or updating specific records based on certain conditions. The function requires the table name and optionally allows a where clause to target specific rows. Only available in a migrator CFC.

NameTypeRequiredDefaultDescription
tablestringyesThe table name where the record is
wherestringnoThe where clause, i.e admin = 1
1. Update the `active` column to 0 for all admin users in a migration
updateRecord(table="users", where="admin = 1", active=0);

2. Update a specific product record by ID
updateRecord(table="products", where="id = 42", price=19.99, stock=100);