Error on startup when reading value LastRun_BackgroundDatabaseUpgrade (#319)
Fixes #300
This commit is contained in:
@@ -196,6 +196,11 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
string SettingName = (string)dataRow["Setting"];
|
string SettingName = (string)dataRow["Setting"];
|
||||||
|
|
||||||
|
if (SettingName.StartsWith("LastRun_"))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Break");
|
||||||
|
}
|
||||||
|
|
||||||
if (AppSettings.ContainsKey(SettingName))
|
if (AppSettings.ContainsKey(SettingName))
|
||||||
{
|
{
|
||||||
AppSettings.Remove(SettingName);
|
AppSettings.Remove(SettingName);
|
||||||
|
@@ -9,7 +9,20 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
public class Database
|
public class Database
|
||||||
{
|
{
|
||||||
public static int schema_version = 0;
|
private static int _schema_version { get; set; } = 0;
|
||||||
|
public static int schema_version
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
//Logging.Log(Logging.LogType.Information, "Database Schema", "Schema version is " + _schema_version);
|
||||||
|
return _schema_version;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
//Logging.Log(Logging.LogType.Information, "Database Schema", "Setting schema version " + _schema_version);
|
||||||
|
_schema_version = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Database()
|
public Database()
|
||||||
{
|
{
|
||||||
@@ -80,7 +93,16 @@ namespace gaseous_server.Classes
|
|||||||
ExecuteCMD(sql, dbDict);
|
ExecuteCMD(sql, dbDict);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 1000; i < 10000; i++)
|
sql = "SELECT schema_version FROM schema_version;";
|
||||||
|
dbDict = new Dictionary<string, object>();
|
||||||
|
DataTable SchemaVersion = ExecuteCMD(sql, dbDict);
|
||||||
|
int OuterSchemaVer = (int)SchemaVersion.Rows[0][0];
|
||||||
|
if (OuterSchemaVer == 0)
|
||||||
|
{
|
||||||
|
OuterSchemaVer = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = OuterSchemaVer; i < 10000; i++)
|
||||||
{
|
{
|
||||||
string resourceName = "gaseous_server.Support.Database.MySQL.gaseous-" + i + ".sql";
|
string resourceName = "gaseous_server.Support.Database.MySQL.gaseous-" + i + ".sql";
|
||||||
string dbScript = "";
|
string dbScript = "";
|
||||||
@@ -96,7 +118,7 @@ namespace gaseous_server.Classes
|
|||||||
// apply script
|
// apply script
|
||||||
sql = "SELECT schema_version FROM schema_version;";
|
sql = "SELECT schema_version FROM schema_version;";
|
||||||
dbDict = new Dictionary<string, object>();
|
dbDict = new Dictionary<string, object>();
|
||||||
DataTable SchemaVersion = ExecuteCMD(sql, dbDict);
|
SchemaVersion = ExecuteCMD(sql, dbDict);
|
||||||
if (SchemaVersion.Rows.Count == 0)
|
if (SchemaVersion.Rows.Count == 0)
|
||||||
{
|
{
|
||||||
// something is broken here... where's the table?
|
// something is broken here... where's the table?
|
||||||
@@ -107,6 +129,8 @@ namespace gaseous_server.Classes
|
|||||||
{
|
{
|
||||||
int SchemaVer = (int)SchemaVersion.Rows[0][0];
|
int SchemaVer = (int)SchemaVersion.Rows[0][0];
|
||||||
Logging.Log(Logging.LogType.Information, "Database", "Schema version is " + SchemaVer);
|
Logging.Log(Logging.LogType.Information, "Database", "Schema version is " + SchemaVer);
|
||||||
|
// update schema version variable
|
||||||
|
Database.schema_version = SchemaVer;
|
||||||
if (SchemaVer < i)
|
if (SchemaVer < i)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -125,9 +149,6 @@ namespace gaseous_server.Classes
|
|||||||
|
|
||||||
// run post-upgrade code
|
// run post-upgrade code
|
||||||
DatabaseMigration.PostUpgradeScript(i, _ConnectorType);
|
DatabaseMigration.PostUpgradeScript(i, _ConnectorType);
|
||||||
|
|
||||||
// update schema version variable
|
|
||||||
Database.schema_version = i;
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user