mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[DEVOPS-1218] Add dryrun mode to MsSqlMigratorUtility (#3795)
* Add dryrun mode to MsSqlMigratorUtility * Fix * Update util/MsSqlMigratorUtility/Program.cs Co-authored-by: Matt Bishop <mbishop@bitwarden.com> * Update util/MsSqlMigratorUtility/Program.cs Co-authored-by: Matt Bishop <mbishop@bitwarden.com> * Update util/MsSqlMigratorUtility/Program.cs Co-authored-by: Matt Bishop <mbishop@bitwarden.com> * Fixes * Fix using * Format * Update util/MsSqlMigratorUtility/Program.cs Co-authored-by: Matt Bishop <mbishop@bitwarden.com> * Fixes * Fix after merge * Fix * Fix * Remove unnecessary param name --------- Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
This commit is contained in:
@ -15,21 +15,23 @@ internal class Program
|
||||
[Option('r', "repeatable", Description = "Mark scripts as repeatable")]
|
||||
bool repeatable = false,
|
||||
[Option('f', "folder", Description = "Folder name of database scripts")]
|
||||
string folderName = MigratorConstants.DefaultMigrationsFolderName)
|
||||
=> MigrateDatabase(databaseConnectionString, repeatable, folderName);
|
||||
string folderName = MigratorConstants.DefaultMigrationsFolderName,
|
||||
[Option('d', "dry-run", Description = "Print the scripts that will be applied without actually executing them")]
|
||||
bool dryRun = false
|
||||
) => MigrateDatabase(databaseConnectionString, repeatable, folderName, dryRun);
|
||||
|
||||
private static bool MigrateDatabase(string databaseConnectionString,
|
||||
bool repeatable = false, string folderName = "")
|
||||
bool repeatable = false, string folderName = "", bool dryRun = false)
|
||||
{
|
||||
var migrator = new DbMigrator(databaseConnectionString);
|
||||
bool success;
|
||||
if (!string.IsNullOrWhiteSpace(folderName))
|
||||
{
|
||||
success = migrator.MigrateMsSqlDatabaseWithRetries(true, repeatable, folderName);
|
||||
success = migrator.MigrateMsSqlDatabaseWithRetries(true, repeatable, folderName, dryRun);
|
||||
}
|
||||
else
|
||||
{
|
||||
success = migrator.MigrateMsSqlDatabaseWithRetries(true, repeatable);
|
||||
success = migrator.MigrateMsSqlDatabaseWithRetries(true, repeatable, dryRun: dryRun);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
Reference in New Issue
Block a user