Add DropDatabase configuration setting

God help me...
This commit is contained in:
Cyberboss
2018-09-04 15:58:56 -04:00
parent 18c9b23a32
commit 0edee48223
3 changed files with 12 additions and 0 deletions
@@ -29,5 +29,10 @@
/// If the database should use direct table creation instead of automatic migrations. Should not be used in production!
/// </summary>
public bool NoMigrations { get; set; }
/// <summary>
/// If the database should be deleted on application startup. Should not be used in production!
/// </summary>
public bool DropDatabase { get; set; }
}
}
@@ -140,6 +140,12 @@ namespace Tgstation.Server.Host.Models
{
Logger.LogInformation("Migrating database...");
if (databaseConfiguration.DropDatabase)
{
Logger.LogCritical("DropDatabase configuration option set! Dropping any existing database...");
await Database.EnsureDeletedAsync(cancellationToken).ConfigureAwait(false);
}
var wasEmpty = false;
if (databaseConfiguration.NoMigrations)
{
@@ -30,6 +30,7 @@
},
"Database": {
"NoMigrations": false,
"DropDatabase": false,
"DatabaseType": "SqlServer",
"ResetAdminPassword": false,
"ConnectionString": "Data Source=(local);Initial Catalog=TGS;Integrated Security=True"