I want to have a unique constraint on a column which I am going to populate with GUIDs. However, my data contains null values for this columns. How do I create the constraint that allows multiple null values using fluent migrator without violating the unique constraint?
I found a workaround for SqlServer here. So it is possible to use FluentMigrator's IfDatabase and execute raw SQL for SqlServer. But I'd like to find a solution that is not system dependent.
SQLServer solution :
IfDatabase("sqlserver").Execute.Sql("
CREATE UNIQUE NONCLUSTERED INDEX foo
ON dbo.bar(key)
WHERE key IS NOT NULL;
");