Adding not null columns to an existing table with data

1,577 views
Skip to first unread message

kberridge

unread,
Mar 30, 2010, 5:31:28 PM3/30/10
to FluentMigrator Google Group
Hey,
I just recently started trying to use Fluent Migrator. Today I ran
into a scenario in which I am adding some not null columns to an
existing table which already has data in it.

I was expecting to write something like:

Create.Column( "NewColumn" ).OnTable( "Tbl" ).AsString();

Execute.Sql( "update Tbl set NewColumn = 'default'" );

Alter.Column( "NewColumn" ).OnTable( "Tbl" ).AsString().NotNullable();

But there does not seem to be any kind of Alter column mechanism. Am
I just over looking it, or is there another way to accomplish this?

Thanks!
Kevin

Shane Walters

unread,
Mar 30, 2010, 6:01:52 PM3/30/10
to FluentMigrator Google Group
Kevin,

Altering a column is a known issue. http://github.com/enkari/fluentmigrator/issues#issue/3

Did you try the .WithDefault syntax?

Create.Column( "NewColumn" ).OnTable( "Tbl" ).AsString().WithDefault("default").

-Shane

Sean Chambers

unread,
Mar 30, 2010, 7:11:11 PM3/30/10
to fluentmigrato...@googlegroups.com
This is definitely a feature that we're missing that we need before we
think of saying fm is a 1.0 in my mind. I could look at adding it over
the weekend or if someone else wants to take a stab at it.

Sean

On Mar 30, 2010, at 6:01 PM, Shane Walters
<shane.si...@gmail.com> wrote:

> --
> You received this message because you are subscribed to the Google
> Groups "FluentMigrator Google Group" group.
> To post to this group, send email to fluentmigrato...@googlegroups.com
> .
> To unsubscribe from this group, send email to fluentmigrator-goog...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/fluentmigrator-google-group?hl=en
> .
>

Reply all
Reply to author
Forward
0 new messages