Example #1
0
 private static int Main(string[] commandLine)
 {
     try
     {
         var args = ParseCommandLine(commandLine);
         User.OnNotify += Console.WriteLine;
         using (var db = new Target(args.ConnectionString, args.IsTestDatabase))
         {
             Console.WriteLine();
             db.MigrateTo(args.TargetVersion)
                 .UsingMigrationsFrom(args.Migrations)
                 .ExecuteAll();
         }
     }
     catch (TerminateProgramWithMessageException ex)
     {
         Console.Write(ex.Message);
         return ex.ErrorLevel;
     }
     catch (Exception ex)
     {
         Console.WriteLine();
         Console.WriteLine("!!");
         Console.WriteLine("!! Unexpected error encountered.");
         Console.WriteLine("!! Please report it so we can improve the migration tool.");
         Console.WriteLine("!!");
         Console.WriteLine();
         Console.WriteLine();
         Console.WriteLine(ex);
         Console.WriteLine();
         return 100;
     }
     return 0;
 }
 public void TargetShouldDisposeItsDatabase()
 {
     var tracer = new DatabaseLocalMemory();
     var testSubject = new Target(tracer);
     testSubject.Dispose();
     tracer.IsDisposed.Should().BeTrue();
 }
 public void TargetShouldConnectToNonProductionDatabasesCorrectly()
 {
     const string connectionString = "some fake connection string;";
     var testSubject = new Target(connectionString, true);
     testSubject.Database.Should().BeOfType<DatabaseRemote>();
     testSubject.Database.IsTestDatabase.Should().BeTrue();
 }
 public void TargetShouldCreateADatabase()
 {
     const string connectionString = "some fake connection string;";
     var testSubject = new Target(connectionString, false);
     testSubject.Database.Should().BeOfType<DatabaseRemote>();
     ((DatabaseRemote) testSubject.Database).ShouldHave()
         .Properties(t => t.ConnectionString)
         .EqualTo(new {ConnectionString = ExpectedConnectionString(connectionString)});
     testSubject.Database.IsTestDatabase.Should().BeFalse();
 }
Example #5
0
 public override bool Execute()
 {
     try
     {
         User.OnNotify += message => this.Log.LogMessage(message);
         using (var db = new Target(this.ConnectionString, this.IsTestDatabase))
         {
             db.MigrateTo(this.TargetVersion)
                 .UsingMigrationsFrom(this.MigrationFolderName)
                 .ExecuteAll();
         }
     }
     catch (TerminateProgramWithMessageException ex)
     {
         this.Log.LogError(ex.Message);
         return false;
     }
     catch (Exception ex)
     {
         this.Log.LogErrorFromException(ex, true);
         return false;
     }
     return true;
 }