mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-12 07:16:56 +08:00
feat: migrate from SQLite to PostgreSQL + Redis architecture
Major database migration to modernize the AI trading system:
• **Database Migration**:
- Add PostgreSQL 15 and Redis 7 services to docker-compose
- Create comprehensive PostgreSQL schema with proper indexes and triggers
- Implement DatabaseInterface for multi-database support
- Add automatic environment-based database selection
• **Infrastructure**:
- PostgreSQL: ACID transactions, better concurrency, JSON support
- Redis: High-performance caching layer (prepared for future use)
- Docker services with health checks and dependency management
- Persistent volumes for data safety
• **Code Refactoring**:
- Abstract database operations through DatabaseInterface
- Implement PostgreSQL-specific operations with proper syntax
- Update all SQL queries to support both SQLite and PostgreSQL
- Fix foreign key constraints and data type conversions
• **Migration Tools**:
- Automated data migration script from SQLite to PostgreSQL
- Complete backup and restore procedures
- One-click migration script with validation
• **Compatibility**:
- Backward compatible with existing SQLite deployments
- Environment variable driven database selection
- Preserved all existing functionality and data
🎯 Benefits: Better performance, scalability, and reliability for production deployments
This commit is contained in:
4
main.go
4
main.go
@@ -41,7 +41,7 @@ type ConfigFile struct {
|
||||
}
|
||||
|
||||
// syncConfigToDatabase 从config.json读取配置并同步到数据库
|
||||
func syncConfigToDatabase(database *config.Database) error {
|
||||
func syncConfigToDatabase(database config.DatabaseInterface) error {
|
||||
// 检查config.json是否存在
|
||||
if _, err := os.Stat("config.json"); os.IsNotExist(err) {
|
||||
log.Printf("📄 config.json不存在,跳过同步")
|
||||
@@ -110,7 +110,7 @@ func syncConfigToDatabase(database *config.Database) error {
|
||||
}
|
||||
|
||||
// loadBetaCodesToDatabase 加载内测码文件到数据库
|
||||
func loadBetaCodesToDatabase(database *config.Database) error {
|
||||
func loadBetaCodesToDatabase(database config.DatabaseInterface) error {
|
||||
betaCodeFile := "beta_codes.txt"
|
||||
|
||||
// 检查内测码文件是否存在
|
||||
|
||||
Reference in New Issue
Block a user