1

I was taking a look at https://book.cakephp.org/3.0/en/migrations.html but I did not see anything about deleting a row from the database using Migrations...

How can I delete a row from a table using the migrations shell?

Jeffrey L. Roberts
  • 2,844
  • 5
  • 34
  • 69

1 Answers1

2

You can run queries with execute() in the migration files. There is no delete command per say but you can just run a snippet to delete the unwanted row. You should specify up() and down() vs change() in the migration as this is not a supported method in change.

public function up()
{
  $this->execute('DELETE FROM table_name WHERE conditions');
}
KaffineAddict
  • 436
  • 2
  • 11