Enhance database configuration to support multiple data sources
- Updated .env.example to include optional configuration for additional database instances. - Refactored DatabaseConfig in config.go to accommodate a default database and additional instances. - Implemented loadAdditionalDBConfigs function to dynamically load configurations for extra databases. - Modified InitDB function in database.go to establish connections for both default and additional databases. - Updated README.md to document the new configuration options for connecting to multiple databases.
This commit is contained in:
@@ -8,6 +8,13 @@ DB_PORT=3306
|
||||
DB_USER=root
|
||||
DB_PASSWORD=your_password
|
||||
DB_NAME=wx_service
|
||||
# 多数据源(可选)
|
||||
# DB_INSTANCES=lawyer,reporting
|
||||
# DB_LAWYER_HOST=127.0.0.1
|
||||
# DB_LAWYER_PORT=3306
|
||||
# DB_LAWYER_USER=another_user
|
||||
# DB_LAWYER_PASSWORD=another_password
|
||||
# DB_LAWYER_NAME=lawyer
|
||||
|
||||
# JWT配置
|
||||
JWT_SECRET=your-secret-key-change-in-production
|
||||
|
||||
Reference in New Issue
Block a user