Skip to content

Commit 8ac9864

Browse files
authored
Merge pull request #174 from gokhansengun/b-exit-status-for-migrator
Add exit code to migrator to signify program's exit status
2 parents b13695f + 463c1f2 commit 8ac9864

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

aspnet-core/src/AbpCompanyName.AbpProjectName.Migrator/MultiTenantMigrateExecuter.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public MultiTenantMigrateExecuter(
3434
_connectionStringResolver = connectionStringResolver;
3535
}
3636

37-
public void Run(bool skipConnVerification)
37+
public bool Run(bool skipConnVerification)
3838
{
3939
var hostConnStr = _connectionStringResolver.GetNameOrConnectionString(new ConnectionStringResolveArgs(MultiTenancySides.Host));
4040
if (hostConnStr.IsNullOrWhiteSpace())
4141
{
4242
Log.Write("Configuration file should contain a connection string named 'Default'");
43-
return;
43+
return false;
4444
}
4545

4646
Log.Write("Host database: " + ConnectionStringHelper.GetConnectionString(hostConnStr));
@@ -51,7 +51,7 @@ public void Run(bool skipConnVerification)
5151
if (!command.IsIn("Y", "y"))
5252
{
5353
Log.Write("Migration canceled.");
54-
return;
54+
return false;
5555
}
5656
}
5757

@@ -66,7 +66,7 @@ public void Run(bool skipConnVerification)
6666
Log.Write("An error occured during migration of host database:");
6767
Log.Write(ex.ToString());
6868
Log.Write("Canceled migrations.");
69-
return;
69+
return false;
7070
}
7171

7272
Log.Write("HOST database migration completed.");
@@ -108,6 +108,8 @@ public void Run(bool skipConnVerification)
108108
}
109109

110110
Log.Write("All databases have been migrated.");
111+
112+
return true;
111113
}
112114
}
113115
}

aspnet-core/src/AbpCompanyName.AbpProjectName.Migrator/Program.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public static void Main(string[] args)
2626

2727
using (var migrateExecuter = bootstrapper.IocManager.ResolveAsDisposable<MultiTenantMigrateExecuter>())
2828
{
29-
migrateExecuter.Object.Run(_quietMode);
29+
var migrationSucceeded = migrateExecuter.Object.Run(_quietMode);
30+
// exit clean (with exit code 0) if migration is a success, otherwise exit with code 1
31+
var exitCode = Convert.ToInt32(!migrationSucceeded);
32+
33+
Environment.Exit(exitCode);
3034
}
3135

3236
if (!_quietMode)

0 commit comments

Comments
 (0)