Skip to content

Migrator

removeRecord()

removeRecord() — returns void

Available in: migration Category: Migration Functions

Used to delete specific records from a database table within a migration CFC. This is useful when you need to clean up obsolete data, remove test data, or correct records as part of a schema migration. You can optionally provide a where clause to target specific rows. If no where clause is provided, the behavior depends on the database; usually, no records are removed unless explicitly specified. Only available in a migration CFC.

NameTypeRequiredDefaultDescription
tablestringyesThe table name to remove the record from
wherestringnoThe where clause, i.e id = 123
1. Remove a specific record by ID
removeRecord(table="users", where="id = 42");

2. Remove multiple records matching a condition
removeRecord(table="orders", where="status = 'cancelled'");

3. Remove all records from a table (use with caution)
removeRecord(table="temporary_data", where="1=1");