= Made table name generic

This commit is contained in:
Matthew Cech
2019-05-23 01:12:32 -07:00
parent b71debb9d2
commit 7fefa5f89c
2 changed files with 21 additions and 13 deletions
+10 -2
View File
@@ -28,14 +28,22 @@ public class DatabaseDriver
driver = null; driver = null;
} }
// Makes sure a table exists with the specified name.
// The keyName specifies the key column label, and the valueName specifies the value column label.
public void EnsureTableExists(String tableName, String keyName, String valueName)
{
// Require a global table if it doesn't exist already
driver.ExecuteStatement("CREATE TABLE IF NOT EXISTS " + tableName + " (" + keyName + " text PRIMARY KEY, " + valueName + " text);", null);
}
// Set up and create a table in the database // Set up and create a table in the database
public boolean Connect() public boolean Connect()
{ {
driver = new JDBCDriverSQLite(); driver = new JDBCDriverSQLite();
driver.Connect(); driver.Connect();
// Require a global table if it doesn't exist already // Verify tables we want to use exist
driver.ExecuteStatement("CREATE TABLE IF NOT EXISTS " + globalTableName + " (" + globalKeyName + " text PRIMARY KEY, " + globalValueName + " text);", null); EnsureTableExists(globalTableName, globalKeyName, globalValueName); // General table. Do not remove.
return true; return true;
} }
+11 -11
View File
@@ -68,6 +68,17 @@ public class Superintendent
return true; return true;
} }
// Only called once per command. Good for lazily updating.
// Happens just before the command / plugin runs.
public static boolean PerCommandUpkeepPre()
{
// Upkeep localization system's file monitoring
LocStrings.Upkeep();
LocCommands.Upkeep();
return true;
}
// This is for stuff that we need to do on a regular basis, but don't // This is for stuff that we need to do on a regular basis, but don't
// necessarily want running at all points in time. // necessarily want running at all points in time.
// Happens just after the command / plugin runs. // Happens just after the command / plugin runs.
@@ -81,15 +92,4 @@ public class Superintendent
return true; return true;
} }
// Only called once per command. Good for lazily updating.
// Happens just before the command / plugin runs.
public static boolean PerCommandUpkeepPre()
{
// Upkeep localization system's file monitoring
LocStrings.Upkeep();
LocCommands.Upkeep();
return true;
}
} }