Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing a row form the database when working with the fluent migration

I am new to fluent Migrations. I want to simply delete a row from the database can you please guide me how this can be done. or point me out in the right direction if this questions is already answered elsewhere on stackoverflow. I dont want to use the dynamic sql in the migration script.

thanks.

like image 644
hussian Avatar asked Oct 27 '25 09:10

hussian


2 Answers

To delete a row in your migration just do the following:

//Delete all rows where MyColumn = 123
Delete.FromTable("MyTable").Row(new { MyColumn = "123" }); 

The documentation for FluentMigrator is a great place for questions like this. The article you're looking for can be found here.

like image 143
FLeX Avatar answered Oct 29 '25 23:10

FLeX


I found the answer from the wiki . below is the format which can be used to do the migration for deleting row from the database

Delete.FromTable("Users").Row(new { FirstName = "John" }); // delete all rows with FirstName==John

like image 25
hussian Avatar answered Oct 29 '25 23:10

hussian