Merge pull request #1811 from AxeelAnder/sqliteconf

Make sqlite db path configurable
This commit is contained in:
Lucas Nicodemus 2020-05-20 10:22:53 -07:00 committed by GitHub
commit 5132a83e96
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 1 deletions

View file

@ -4,6 +4,7 @@ This is the rolling changelog for TShock for Terraria. Use past tense when addin
## Upcoming changes
* Update player spawn related things to 1.4. `Terraria.Player.Spawn` method now has a required argument, `PlayerSpawnContext context`. (@AxeelAnder)
* Make sqlite db path configurable. (@AxeelAnder)
## TShock 4.4.0 (Pre-release 4)
* Debug logging now provides ConsoleDebug and ILog has been updated to support the concept of debug logs. Debug logs are now controlled by `config.json` instead of by preprocessor debug flag. (@hakusaro)

View file

@ -140,6 +140,10 @@ namespace TShockAPI
[Description("The type of database to use when storing data (either \"sqlite\" or \"mysql\").")]
public string StorageType = "sqlite";
/// <summary>The path of sqlite db.</summary>
[Description("The path of sqlite db.")]
public string SqliteDBPath = "tshock.sqlite";
/// <summary>The MySQL hostname and port to direct connections to.</summary>
[Description("The MySQL hostname and port to direct connections to.")]
public string MySqlHost = "localhost:3306";

View file

@ -264,7 +264,8 @@ namespace TShockAPI
{
if (Config.StorageType.ToLower() == "sqlite")
{
string sql = Path.Combine(SavePath, "tshock.sqlite");
string sql = Path.Combine(SavePath, Config.SqliteDBPath);
Directory.CreateDirectory(Path.GetDirectoryName(sql));
DB = new SqliteConnection(string.Format("uri=file://{0},Version=3", sql));
}
else if (Config.StorageType.ToLower() == "mysql")