Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to drop column with FluentMigrator?

I am using .Net4.5 and C#, I am working on one of database migrations using FluentMigrator. I am able to alter tables and add columns by using

Alter.Table("Items").InSchema("Pricing")             .AddColumn("CanBe").AsBoolean().NotNullable() 

However I need to drop some existing columns and nor DeleteColumn nor DropColumn methods are not on IAlterTableAddColumnOrAlterColumnOrSchemaSyntax interface.

How do I drop columns using FluentMigrator?

like image 381
Matas Vaitkevicius Avatar asked Jul 07 '16 10:07

Matas Vaitkevicius


People also ask

How do you drop a column?

Right-click the column you want to delete and choose Delete Column from the shortcut menu. If the column participates in a relationship (FOREIGN KEY or PRIMARY KEY), a message prompts you to confirm the deletion of the selected columns and their relationships. Choose Yes.

What is fluent Migrator?

FluentMigrator is a database migration framework for . NET written in C#. The basic idea is that you can create migrations which are simply classes that derive from the Migration base class and have a Migration attribute with a unique version number attached to them.


1 Answers

Found it myself:

It has to go as separate statement.

Alter.Table("Items").InSchema("Pricing")         .AddColumn("CanBe").AsBoolean().NotNullable();  Delete.Column("AllowSubscription").FromTable("Items").InSchema("Pricing"); 
like image 119
Matas Vaitkevicius Avatar answered Sep 17 '22 21:09

Matas Vaitkevicius