Migrator
removeRecord()
Signature
Section titled “Signature”removeRecord() — returns void
Available in: migration
Category: Migration Functions
Description
Section titled “Description”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.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
table | string | yes | — | The table name to remove the record from |
where | string | no | — | The where clause, i.e id = 123 |
Examples
Section titled “Examples”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");