Simplify database support to SQLite only

Removed PostgreSQL and MySQL support to reduce complexity:
- Removed postgres and mysql drivers from go.mod
- Simplified database.Initialize() to only use SQLite
- Simplified DatabaseConfig struct (removed Driver, Host, Port, User, Password, SSLMode)
- Removed GetDSN() method from config
- Removed --db CLI flag (only --db-name remains for specifying SQLite file path)
- Updated .env.example to remove MySQL/PostgreSQL options
- Updated README_GOLANG.md to reflect SQLite-only support
- Ran go mod tidy to clean up dependencies

This makes the application simpler to deploy and maintain, with no
external database dependencies required.
This commit is contained in:
Claude 2025-11-05 11:23:40 +00:00
parent 4aaa889634
commit 65f1265555
No known key found for this signature in database
7 changed files with 44 additions and 107 deletions

View file

@ -7,8 +7,6 @@ import (
"github.com/TracksApp/tracks/internal/config"
"github.com/TracksApp/tracks/internal/models"
"gorm.io/driver/mysql"
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
@ -19,20 +17,7 @@ var DB *gorm.DB
// Initialize sets up the database connection
func Initialize(cfg *config.DatabaseConfig) error {
var dialector gorm.Dialector
switch cfg.Driver {
case "sqlite":
dialector = sqlite.Open(cfg.GetDSN())
case "mysql":
dialector = mysql.Open(cfg.GetDSN())
case "postgres":
dialector = postgres.Open(cfg.GetDSN())
default:
return fmt.Errorf("unsupported database driver: %s", cfg.Driver)
}
db, err := gorm.Open(dialector, &gorm.Config{
db, err := gorm.Open(sqlite.Open(cfg.Name), &gorm.Config{
Logger: logger.Default.LogMode(logger.Info),
NowFunc: func() time.Time {
return time.Now().UTC()