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 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; }