public void Down(IMigration migration) { var name = migration.GetType().Name; _announcer.Heading(name + ": reverting"); CaughtExceptions = new List<Exception>(); var context = new MigrationContext(Conventions, Processor); migration.GetDownExpressions(context); _stopWatch.Start(); ExecuteExpressions(context.Expressions); _stopWatch.Stop(); _announcer.Say(name + ": reverted"); _announcer.ElapsedTime(_stopWatch.ElapsedTime()); }
public void Down(IMigration migration) { var name = migration.GetType().Name; _announcer.Announce(name + ": reverting"); CaughtExceptions = new List<Exception>(); var context = new MigrationContext(Conventions); migration.GetDownExpressions(context); _stopWatch.Start(); ExecuteExpressions(context.Expressions); _stopWatch.Stop(); var elapsed = _stopWatch.ElapsedTime().TotalSeconds; _announcer.Announce(name + ": reverted (" + elapsed + "s" + ")"); }
public void Up(IMigration migration) { var name = GetMigrationName(migration); _announcer.Heading(string.Format("{0} migrating", name)); CaughtExceptions = new List<Exception>(); var context = new MigrationContext(Conventions, Processor, MigrationAssembly, ApplicationContext) { Factory = _migrationFactory }; migration.GetUpExpressions(context); _stopWatch.Start(); ExecuteExpressions(context.Expressions); _stopWatch.Stop(); _announcer.Say(string.Format("{0} migrated", name)); _announcer.ElapsedTime(_stopWatch.ElapsedTime()); }
private void ExecuteMigration(IMigration migration, Action<IMigration, IMigrationContext> getExpressions) { CaughtExceptions = new List<Exception>(); var context = new MigrationContext(Conventions, Processor, MigrationAssembly, ApplicationContext, Processor.ConnectionString); getExpressions(migration, context); _migrationValidator.ApplyConventionsToAndValidateExpressions(migration, context.Expressions); ExecuteExpressions(context.Expressions); }
private MigrationContext ExecuteTestMigration(IEnumerable<string> databaseType, IQuerySchema processor, params Action<IIfDatabaseExpressionRoot>[] fluentExpression) { // Arrange var context = new MigrationContext(new MigrationConventions(), processor ?? new JetProcessor(new OleDbConnection(), null, null, null), new SingleAssembly(GetType().Assembly), null, ""); var expression = new IfDatabaseExpressionRoot(context, databaseType.ToArray()); // Act if (fluentExpression == null || fluentExpression.Length == 0) expression.Create.Table("Foo").WithColumn("Id").AsInt16(); else { foreach (var action in fluentExpression) { action(expression); } } return context; }
public void Down(IMigration migration) { var name = GetMigrationName(migration); _announcer.Heading(string.Format("{0} reverting", name)); CaughtExceptions = new List<Exception>(); var context = new MigrationContext(Conventions, Processor, Assembly.GetAssembly(migration.GetType()), ApplicationContext); migration.GetDownExpressions(context); _stopWatch.Start(); ExecuteExpressions(context.Expressions); _stopWatch.Stop(); _announcer.Say(string.Format("{0} reverted", name)); _announcer.ElapsedTime(_stopWatch.ElapsedTime()); }
public TimeSpan Up(IMigration migration) { var name = migration.GetType().Name; _announcer.Heading(name + ": migrating"); CaughtExceptions = new List<Exception>(); var context = new MigrationContext(Conventions, Processor,MigrationAssembly); migration.GetUpExpressions(context); _stopWatch.Start(); ExecuteExpressions(context.Expressions); _stopWatch.Stop(); _announcer.Say(name + ": migrated"); _announcer.ElapsedTime(_stopWatch.ElapsedTime()); return _stopWatch.ElapsedTime(); }
public void CanAutoReverse() { _announcer.Setup(x => x.Say(It.IsRegex(containsAll("CreateTable")))); _stopWatch.Setup(x => x.ElapsedTime()).Returns(new TimeSpan(0, 0, 0, 1, 3)); _runner.Conventions.GetAutoReverse = () => true; TestAutoReverseMigration test = new TestAutoReverseMigration(); IMigrationContext testContext = new MigrationContext(_runner.Conventions, _runner.Processor); test.GetDownExpressions(testContext); testContext.Expressions.Count.ShouldBeGreaterThan(0); }