Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAli Golzar <57574919+aliglzr@users.noreply.github.com>2025-05-21 13:04:38 +0300
committerGitHub <noreply@github.com>2025-05-21 13:04:38 +0300
commit3850e2f070bb3c1227b78dcd1e8a34a89a9e9906 (patch)
tree3a29b65f47f382494b669b29f7c8695f66527df4 /main.go
parent1b1cbfff422e6de58a6f524336b19ec809eb45f0 (diff)
feat: Add MySQL database support (#3024)MySQL-databases
* feat: Add MySQL database support - Add MySQL database support with environment-based configuration - Fix MySQL compatibility issue with 'key' column name - Maintain SQLite as default database - Add proper validation for MySQL configuration - Test and verify compatibility with existing database - Replaced raw SQL queries using JSON_EACH functions with standard GORM queries - Modified functions to handle JSON parsing in Go code instead of database since JSON_EACH is not available on MySQL or MariaDB: - getAllEmails() - GetClientTrafficByID() - getFallbackMaster() - MigrationRemoveOrphanedTraffics() The system now supports both MySQL and SQLite databases, with SQLite remaining as the default option. MySQL connection is only used when explicitly configured through environment variables. * refactor: prefix env variables of database with XUI_ to support direct environment usage without .env file All database configuration environment variables now start with the XUI_ prefix to avoid conflicts and allow configuration via system-level environment variables, not just the .env file.
Diffstat (limited to 'main.go')
-rw-r--r--main.go1
1 files changed, 1 insertions, 0 deletions
diff --git a/main.go b/main.go
index dcbd3c9e..a19e4760 100644
--- a/main.go
+++ b/main.go
@@ -105,6 +105,7 @@ func runWebServer() {
default:
server.Stop()
subServer.Stop()
+ database.CloseDB()
log.Println("Shutting down servers.")
return
}