Refactoring migrations by adding an abstract class to all expressions that allow for processing prior to returning an sql statement.

Refactoring the current sql syntax providers to better work with sql ce, sql server and mysql.
Adding migrations for v4.8 and v6.0.
Adding test cases for upgrading from 4.7 to 6.0 for the 3 database providers - sql ce, sql server and mysql.
Adding product name to the MigrationAttribute, which adds more flexibility to the MigrationRunner.
Fixing schema creation for mysql, which broke during a previous refactor task.
This commit is contained in:
Morten Christensen
2012-12-27 18:52:47 -01:00
parent 5b1ce5fe67
commit 64af0a610b
77 changed files with 875 additions and 305 deletions

View File

@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence
db.DropTable(tableName);
}
if (!tableExist)
if (tableExist == false)
{
using (var transaction = db.GetTransaction())
{
@@ -64,14 +64,14 @@ namespace Umbraco.Core.Persistence
var e = new TableCreationEventArgs();
//Turn on identity insert if db provider is not mysql
if (ApplicationContext.Current.DatabaseContext.ProviderName.Contains("MySql") == false && tableDefinition.Columns.Any(x => x.IsIdentity))
if (SyntaxConfig.SqlSyntaxProvider.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} ON ", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName))));
//Call the NewTable-event to trigger the insert of base/default data
NewTable(tableName, db, e);
//Turn off identity insert if db provider is not mysql
if (ApplicationContext.Current.DatabaseContext.ProviderName.Contains("MySql") == false && tableDefinition.Columns.Any(x => x.IsIdentity))
if (SyntaxConfig.SqlSyntaxProvider.SupportsIdentityInsert() && tableDefinition.Columns.Any(x => x.IsIdentity))
db.Execute(new Sql(string.Format("SET IDENTITY_INSERT {0} OFF;", SyntaxConfig.SqlSyntaxProvider.GetQuotedTableName(tableName))));
}
@@ -89,16 +89,6 @@ namespace Umbraco.Core.Persistence
LogHelper.Info<Database>(string.Format("Create Index sql {0}:\n {1}", createdIndex, sql));
}
//Specific to Sql Ce - look for changes to Identity Seed
//if (ApplicationContext.Current.DatabaseContext.ProviderName.Contains("SqlServerCe"))
//{
// var seedSql = SyntaxConfig.SqlSyntaxProvider.ToAlterIdentitySeedStatements(tableDefinition);
// foreach (var sql in seedSql)
// {
// int createdSeed = db.Execute(new Sql(sql));
// }
//}
transaction.Complete();
}
}
@@ -144,6 +134,11 @@ namespace Umbraco.Core.Persistence
NewTable -= PetaPocoExtensions_NewTable;
}
public static DatabaseProviders GetDatabaseProvider(this Database db)
{
return ApplicationContext.Current.DatabaseContext.DatabaseProvider;
}
private static void PetaPocoExtensions_NewTable(string tableName, Database db, TableCreationEventArgs e)
{
var baseDataCreation = new BaseDataCreation(db);