From f2e88cbedc3cb6985c39958e2d4563c041776c08 Mon Sep 17 00:00:00 2001 From: Sakura Akeno Isayeki Date: Fri, 23 May 2025 13:47:35 +0200 Subject: [PATCH] feat: Add connection strings parameters for databases Allows specifying complete connection strings for SQLite, MySQL, and Postgres, overriding individual host and credential properties when specified, to provide more flexible database configuration. --- TShockAPI/Configuration/TShockConfig.cs | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/TShockAPI/Configuration/TShockConfig.cs b/TShockAPI/Configuration/TShockConfig.cs index 64fbf77c..63fb4cca 100644 --- a/TShockAPI/Configuration/TShockConfig.cs +++ b/TShockAPI/Configuration/TShockConfig.cs @@ -532,10 +532,31 @@ namespace TShockAPI.Configuration [Description("The type of database to use when storing data (either \"sqlite\", \"mysql\" or \"postgres\").")] public string StorageType = "sqlite"; + /// + /// The connection string to use when connecting to a SQLite database. + /// + /// This property will override the property, if used. + [Description("The connection string to use when connecting to a SQLite database. This property will override the SqliteDBPath property, if used.")] + public string SqliteConnectionString = ""; + /// The path of sqlite db. [Description("The path of sqlite db.")] public string SqliteDBPath = "tshock.sqlite"; + /// + /// The connection string to use when connecting to a MySQL database. + /// + /// + /// This property will override the + /// , + /// , + /// , + /// and properties, if used. + /// + [Description("The connection string to use when connecting to a MySQL database. " + + "This property will override the MySqlHost, MySqlDbName, MySqlUsername and MySqlPassword properties, if used.")] + public string MySqlConnectionString = ""; + /// The MySQL hostname and port to direct connections to. [Description("The MySQL hostname and port to direct connections to.")] public string MySqlHost = "localhost:3306"; @@ -552,6 +573,20 @@ namespace TShockAPI.Configuration [Description("The password used when connecting to a MySQL database.")] public string MySqlPassword = ""; + /// + /// The connection string to use when connecting to a Postgres database. + /// + /// + /// This property will override the + /// , + /// , + /// , + /// and properties, if used. + /// + [Description("The connection string to use when connecting to a Postgres database. " + + "This property will override the PostgresHost, PostgresDbName, PostgresUsername and PostgresPassword properties, if used.")] + public string PostgresConnectionString = ""; + ///The Postgres hostname and port to direct connections to. [Description("The Postgres hostname and port to direct connections to.")] public string PostgresHost = "";