public MigrationRunner(MigrationConfig config) { this.Configuration = config; var auth = config.TrustedConnection ? "Trusted_Connection=true" : $"User Id={config.Username};Password={config.Password}"; this.ConnectionString = $"Server={config.Server};Database={config.Database};{auth}"; this.Connection = new SqlConnection(this.ConnectionString); }
/// <summary> /// Entry point for application. /// </summary> /// <param name="args"> /// Command line params /// </param> /// <remarks> /// Usage: migrate databasename -u sa -p password /// Usage: migrate databasename -m 201601251230 /// <database> Database name /// -m <id> Migration id, defaults to all migrations /// -u <username> Database username, defaults to sa if a password is provided, /// otherwise uses the current windows account. /// -p <password> Database password, defaults to blank /// </remarks> public static void Main(string[] args) { var config = new MigrationConfig(args.ToList()); using (var runner = new MigrationRunner(config)) { var success = runner.Run(); Console.WriteLine( success ? "All pending migrations were applied successfully." : "An error occured processing one of the migrations. Previous migrations were still applied."); } }