Initial work on fluent database migrations

This commit is contained in:
Morten Christensen
2012-11-30 15:01:52 -01:00
parent a5344b4087
commit f59f57fd6a
58 changed files with 1841 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
using Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions;
using Umbraco.Core.Persistence.Migrations.Model;
using ColumnDefinition = Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions.ColumnDefinition;
namespace Umbraco.Core.Persistence.SqlSyntax
{
@@ -75,5 +76,34 @@ namespace Umbraco.Core.Persistence.SqlSyntax
return result > 0;
}
protected override string FormatIdentity(Migrations.Model.ColumnDefinition column)
{
return column.IsIdentity ? GetIdentityString(column) : string.Empty;
}
private static string GetIdentityString(Migrations.Model.ColumnDefinition column)
{
return "IDENTITY(1,1)";
}
protected override string FormatSystemMethods(SystemMethods systemMethod)
{
switch (systemMethod)
{
case SystemMethods.NewGuid:
return "NEWID()";
case SystemMethods.NewSequentialId:
return "NEWSEQUENTIALID()";
case SystemMethods.CurrentDateTime:
return "GETDATE()";
case SystemMethods.CurrentUTCDateTime:
return "GETUTCDATE()";
}
return null;
}
public override string AddColumn { get { return "ALTER TABLE {0} ADD {1}"; } }
}
}