Refactoring database creation, adding sql syntax provider to account for differences in syntax between sql, ce and mysql.
Adding MySql unit test.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Umbraco.Core.Persistence.SqlSyntax.ModelDefinitions;
|
||||
|
||||
namespace Umbraco.Core.Persistence.SqlSyntax
|
||||
{
|
||||
internal class SqlServerSyntaxProvider : SqlSyntaxProviderBase<SqlServerSyntaxProvider>
|
||||
{
|
||||
public static SqlServerSyntaxProvider Instance = new SqlServerSyntaxProvider();
|
||||
|
||||
private SqlServerSyntaxProvider()
|
||||
{
|
||||
StringLengthColumnDefinitionFormat = StringLengthUnicodeColumnDefinitionFormat;
|
||||
StringColumnDefinition = string.Format(StringLengthColumnDefinitionFormat, DefaultStringLength);
|
||||
|
||||
AutoIncrementDefinition = "IDENTITY(1,1)";
|
||||
StringColumnDefinition = "VARCHAR(8000)";
|
||||
GuidColumnDefinition = "UniqueIdentifier";
|
||||
RealColumnDefinition = "FLOAT";
|
||||
BoolColumnDefinition = "BIT";
|
||||
DecimalColumnDefinition = "DECIMAL(38,6)";
|
||||
TimeColumnDefinition = "TIME"; //SQLSERVER 2008+
|
||||
BlobColumnDefinition = "VARBINARY(MAX)";
|
||||
|
||||
InitColumnTypeMap();
|
||||
}
|
||||
|
||||
public override bool DoesTableExist(Database db, string tableName)
|
||||
{
|
||||
var result =
|
||||
db.ExecuteScalar<long>("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = @TableName",
|
||||
new { TableName = tableName });
|
||||
|
||||
return result > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user