Skip to content
Permalink
Browse files

close database connections during the upgrade.

drop old database upgrade files.
fixes #406
  • Loading branch information
tpokorra committed Nov 22, 2019
1 parent d0d67d1 commit 11fe3989961c2a436fd1a6de96040f334ab89654
Showing with 22 additions and 646 deletions.
  1. +14 −11 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/DBUpgrades.cs
  2. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201806_201808.cs
  3. +0 −64 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201808_201809.cs
  4. +0 −4 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201808_201809.sql
  5. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201809_201810.cs
  6. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201810_201811.cs
  7. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201811_201812.cs
  8. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201812_201901.cs
  9. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201901_201902.cs
  10. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201902_201904.cs
  11. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201904_201905.cs
  12. +0 −64 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201905_201906.cs
  13. +0 −21 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201905_201906.sql
  14. +0 −64 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201906_201907.cs
  15. +0 −14 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201906_201907.sql
  16. +0 −44 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201907_201908.cs
  17. +3 −4 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201908_201909.cs
  18. +5 −4 csharp/ICT/Petra/Server/lib/MSysMan/DBUpgrades/Upgrade201909_201910.cs
@@ -40,16 +40,15 @@ public class TDBUpgrades : IDBUpgrades
/// <summary>
/// get current database version
/// </summary>
private static TFileVersionInfo GetCurrentDBVersion()
private static TFileVersionInfo GetCurrentDBVersion(TDataBase ADataBase)
{
TDataBase db = DBAccess.Connect("GetCurrentDBVersion");
TDBTransaction Transaction = new TDBTransaction();
string currentVersion = String.Empty;
db.ReadTransaction(
ADataBase.ReadTransaction(
ref Transaction,
delegate
{
currentVersion = (string)db.ExecuteScalar(
currentVersion = (string)ADataBase.ExecuteScalar(
"SELECT s_default_value_c FROM s_system_defaults where s_default_code_c='CurrentDatabaseVersion'",
Transaction);
});
@@ -60,18 +59,17 @@ private static TFileVersionInfo GetCurrentDBVersion()
/// <summary>
/// set current database version
/// </summary>
private static bool SetCurrentDBVersion(TFileVersionInfo ANewVersion)
private static bool SetCurrentDBVersion(TFileVersionInfo ANewVersion, TDataBase ADataBase)
{
TDBTransaction transaction = new TDBTransaction();
TDataBase db = DBAccess.Connect("TDBUpgrades_SetCurrentDBVersion");
bool SubmitOK = true;
db.WriteTransaction(ref transaction, ref SubmitOK,
ADataBase.WriteTransaction(ref transaction, ref SubmitOK,
delegate
{
string newVersionSql =
String.Format("UPDATE s_system_defaults SET s_default_value_c = '{0}' WHERE s_default_code_c = 'CurrentDatabaseVersion';",
ANewVersion.ToStringDotsHyphen());
db.ExecuteNonQuery(newVersionSql, transaction);
ADataBase.ExecuteNonQuery(newVersionSql, transaction);
});

return true;
@@ -81,10 +79,12 @@ private static bool SetCurrentDBVersion(TFileVersionInfo ANewVersion)
public bool UpgradeDatabase()
{
bool upgraded = false;

TDataBase db = DBAccess.Connect("UpgradeDatabase");

while (true)
{
TFileVersionInfo originalDBVersion = GetCurrentDBVersion();
TFileVersionInfo originalDBVersion = GetCurrentDBVersion(db);
TFileVersionInfo currentDBVersion = originalDBVersion;
TLogging.LogAtLevel(1, "current DB version: " + currentDBVersion.ToStringDotsHyphen());

@@ -112,13 +112,14 @@ public bool UpgradeDatabase()

TLogging.Log("Database Upgrade: applying method " + m.Name);

bool result = (bool)m.Invoke(null, BindingFlags.Static, null, null, null);
object[] parameters = new object[]{db};
bool result = (bool)m.Invoke(null, BindingFlags.Static, null, parameters, null);

if (result == true)
{
upgraded = true;
currentDBVersion = testDBVersion;
SetCurrentDBVersion(currentDBVersion);
SetCurrentDBVersion(currentDBVersion, db);
}

break;
@@ -130,6 +131,8 @@ public bool UpgradeDatabase()
{
break;
}

db.CloseDBConnection();
}

return upgraded;

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 11fe398

Please sign in to comment.
You can’t perform that action at this time.