2015-01-09 13:00:26 +11:00
|
|
|
|
using System;
|
|
|
|
|
|
using Umbraco.Core.Logging;
|
|
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Alter;
|
2012-11-30 15:01:52 -01:00
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Create;
|
|
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Delete;
|
2012-12-26 14:44:42 -01:00
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Execute;
|
2012-12-27 18:52:47 -01:00
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.IfDatabase;
|
2012-11-30 15:01:52 -01:00
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Insert;
|
|
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Rename;
|
|
|
|
|
|
using Umbraco.Core.Persistence.Migrations.Syntax.Update;
|
2015-01-09 13:00:26 +11:00
|
|
|
|
using Umbraco.Core.Persistence.SqlSyntax;
|
2012-11-30 15:01:52 -01:00
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Core.Persistence.Migrations
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class MigrationBase : IMigration
|
|
|
|
|
|
{
|
2015-01-09 13:00:26 +11:00
|
|
|
|
public ISqlSyntaxProvider SqlSyntax { get; private set; }
|
|
|
|
|
|
public ILogger Logger { get; private set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Obsolete("Use the other constructor specifying all dependencies instead")]
|
|
|
|
|
|
protected MigrationBase()
|
|
|
|
|
|
: this(SqlSyntaxContext.SqlSyntaxProvider, LoggerResolver.Current.Logger)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected MigrationBase(ISqlSyntaxProvider sqlSyntax, ILogger logger)
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlSyntax = sqlSyntax;
|
|
|
|
|
|
Logger = logger;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2013-01-18 13:51:40 -01:00
|
|
|
|
internal IMigrationContext Context;
|
2012-11-30 15:01:52 -01:00
|
|
|
|
|
|
|
|
|
|
public abstract void Up();
|
|
|
|
|
|
public abstract void Down();
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void GetUpExpressions(IMigrationContext context)
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
Context = context;
|
2012-11-30 15:01:52 -01:00
|
|
|
|
Up();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public virtual void GetDownExpressions(IMigrationContext context)
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
Context = context;
|
2012-11-30 15:01:52 -01:00
|
|
|
|
Down();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IAlterSyntaxBuilder Alter
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
get { return new AlterSyntaxBuilder(Context); }
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public ICreateBuilder Create
|
|
|
|
|
|
{
|
2015-01-09 15:27:47 +11:00
|
|
|
|
get { return new CreateBuilder(Context, SqlSyntax); }
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IDeleteBuilder Delete
|
|
|
|
|
|
{
|
2015-01-09 15:27:47 +11:00
|
|
|
|
get { return new DeleteBuilder(Context, SqlSyntax); }
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-12-26 14:44:42 -01:00
|
|
|
|
public IExecuteBuilder Execute
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
get { return new ExecuteBuilder(Context); }
|
2012-12-26 14:44:42 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
2012-11-30 15:01:52 -01:00
|
|
|
|
public IInsertBuilder Insert
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
get { return new InsertBuilder(Context); }
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IRenameBuilder Rename
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
get { return new RenameBuilder(Context); }
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public IUpdateBuilder Update
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
get { return new UpdateBuilder(Context); }
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
2012-12-27 18:52:47 -01:00
|
|
|
|
|
|
|
|
|
|
public IIfDatabaseBuilder IfDatabase(params DatabaseProviders[] databaseProviders)
|
|
|
|
|
|
{
|
2013-01-18 13:51:40 -01:00
|
|
|
|
return new IfDatabaseBuilder(Context, databaseProviders);
|
2012-12-27 18:52:47 -01:00
|
|
|
|
}
|
2012-11-30 15:01:52 -01:00
|
|
|
|
}
|
|
|
|
|
|
}
|