public static void Migrate(IMigrationLogger MigrationLogger = null, bool update_database = false) { SchemaUpdate schemaUpdate = new SchemaUpdate(_configuration); if (MigrationLogger == null) { schemaUpdate.Execute(false, update_database); } Migrator.Migrate(schemaUpdate, MigrationLogger, update_database); }
/// <summary> /// Initialises a new instance of the <see cref="MigrationRunData{TConnection}"/> class /// </summary> /// <param name="connection">Connection to use to run the migration</param> /// <param name="logger">Logger to use to log SQL statements run, and other messages</param> /// <param name="direction">Direction to run the migration in</param> public MigrationRunData(TConnection connection, IMigrationLogger logger, MigrationDirection direction) { if (connection == null) { throw new ArgumentNullException(nameof(connection)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } this.Connection = connection; this.Logger = logger; this.Direction = direction; }
public MigrationContext( [NotNull] IServiceContext services, [NotNull] UmbracoDatabase database, [NotNull] CacheHelper cacheHelper, [NotNull] IMigrationRecordRepository migrationRecords, [NotNull] MigrationConfiguration configuration, [CanBeNull] IMigrationLogger logger = null ) { Services = Argument.NotNull(nameof(services), services); Database = Argument.NotNull(nameof(database), database); MigrationRecords = Argument.NotNull(nameof(migrationRecords), migrationRecords); Configuration = Argument.NotNull(nameof(configuration), configuration); Logger = logger; _cacheHelper = cacheHelper; }
void IMigration <DbConnection> .Execute(DbConnection connection, IMigrationLogger logger, MigrationDirection direction) { this.Connection = connection; this.Logger = logger; if (this.UseTransaction) { using (this.Transaction = connection.BeginTransaction(IsolationLevel.Serializable)) { try { if (direction == MigrationDirection.Up) { this.Up(); } else { this.Down(); } this.Transaction.Commit(); } catch { this.Transaction?.Rollback(); throw; } finally { this.Transaction = null; } } } else { if (direction == MigrationDirection.Up) { this.Up(); } else { this.Down(); } } }
void IMigration <IDbConnection> .RunMigration(MigrationRunData <IDbConnection> data) { using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, TimeSpan.FromMinutes(10))) { Connection = data.Connection; Logger = data.Logger; if (data.Direction == MigrationDirection.Up) { Up(); Down(); Up(); } else { Down(); } scope.Complete(); } }
void IMigration <SQLiteConnection> .RunMigration(MigrationRunData <SQLiteConnection> data) { this.Connection = data.Connection; this.Logger = data.Logger; if (this.UseTransaction) { try { this.Connection.BeginTransaction(); if (data.Direction == MigrationDirection.Up) { this.Up(); } else { this.Down(); } this.Connection.Commit(); } catch { this.Connection.Rollback(); throw; } } else { if (data.Direction == MigrationDirection.Up) { this.Up(); } else { this.Down(); } } }
void IMigration <SQLiteConnection> .Execute(SQLiteConnection connection, IMigrationLogger logger, MigrationDirection direction) { this.Connection = connection; this.Logger = logger; if (this.UseTransaction) { try { connection.BeginTransaction(); if (direction == MigrationDirection.Up) { this.Up(); } else { this.Down(); } connection.Commit(); } catch { connection.Rollback(); throw; } } else { if (direction == MigrationDirection.Up) { this.Up(); } else { this.Down(); } } }
public static void Migrate(SchemaUpdate schemaUpdate, IMigrationLogger migrationLogger, bool update_database = false) { schemaUpdate.Execute(migrationLogger.Log(), update_database); }
public IMigrationContext WithLogger(IMigrationLogger logger) { return(new MigrationContext(Services, Database, _cacheHelper, MigrationRecords, Configuration, logger)); }
/// <summary> /// Logs the given log entry with information level /// </summary> /// <param name="logger">The logger instance</param> /// <param name="exception">An optional exception</param> /// <param name="messageFormat">The message format</param> public static void LogInformation(this IMigrationLogger logger, Exception exception, string messageFormat) => logger.Log(MigrationLogLevel.Information, exception, messageFormat, EmptyArgs);
/// <summary> /// Logs the given log entry with debug level /// </summary> /// <param name="logger">The logger instance</param> /// <param name="exception">An optional exception</param> /// <param name="messageFormat">The message format</param> /// <param name="args">An optional collection of message format arguments</param> public static void LogDebug(this IMigrationLogger logger, Exception exception, string messageFormat, params string[] args) => logger.Log(MigrationLogLevel.Debug, exception, messageFormat, args);
/// <summary> /// Logs the given log entry /// </summary> /// <param name="logger">The logger instance</param> /// <param name="level">The log level</param> /// <param name="exception">An optional exception</param> /// <param name="messageFormat">The message format</param> public static void Log(this IMigrationLogger logger, MigrationLogLevel level, Exception exception, string messageFormat) => logger.Log(level, exception, messageFormat);
/// <summary> /// Creates a logger scope with the given information. /// </summary> /// <param name="logger">The logger instance</param> /// <param name="messageFormat">The message format</param> /// <returns>The disposable logger scope</returns> public static IDisposable Scope(this IMigrationLogger logger, string messageFormat) => logger.Scope(messageFormat, EmptyArgs);
public void Execute(IDbConnection connection, IMigrationLogger logger, MigrationDirection direction) { throw new NotImplementedException(); }