dradovic / MigSharp

Mig# (MigSharp) is a .NET framework for database migrations and versioning
Other
106 stars 34 forks source link

Specifying a default constraint of type bool on a DbType.Boolean column causes error #61

Closed DanielStout5 closed 9 years ago

DanielStout5 commented 9 years ago

Attempting to execute a migration containing the following:

db.CreateTable("MyTable")
     .WithNotNullableColumn("IsActive", DbType.Boolean).HavingDefault<bool>(true);

Causes the following error:

MigSharp.General Error: 0 : An error occurred: The name "True" is not permitted in this context.
Valid expressions are constants, constant expressions, and (in some contexts) variables. Column names are not permitted.
CREATE TABLE [dbo].[MyTable](
[IsActive] [bit] NOT NULL CONSTRAINT [MyTable_IsActive_DF]  DEFAULT True;
)

Of course, it's easy to fix it by just using HavingDefault<int>(1) but I think it would be better for it to convert true/false to 1/0 automatically.

dradovic commented 9 years ago

I'll have a look into this.

dradovic commented 9 years ago

Fix released in 2.3.4.