feat: migrate database from SQLite to MySQL with .env configuration

- Replace go-sqlite3 with go-sql-driver/mysql (pure Go, no CGO needed)
- Add joho/godotenv for .env file loading
- Rewrite database/db.go with MySQL-compatible DDL (BIGINT AUTO_INCREMENT, InnoDB, utf8mb4)
- Convert all SQLite-specific SQL: INSERT OR IGNORE → INSERT IGNORE,
  INSERT OR REPLACE → INSERT ... ON DUPLICATE KEY UPDATE,
  datetime('now') → NOW(), date arithmetic → DATE_SUB()
- Add MySQL config fields to config.go (host/port/user/password/database)
- Add .env.example with connection parameter template
- Update Dockerfile: remove CGO/gcc/musl dependency, smaller build
- Update docker-compose.yml: add MySQL service container with healthcheck
- Update CLAUDE.md documentation
This commit is contained in:
2026-06-20 22:40:46 +08:00
parent 6c60b767df
commit 00c1839635
14 changed files with 130 additions and 102 deletions
+3 -1
View File
@@ -6,13 +6,15 @@ require (
github.com/gin-contrib/sessions v1.1.0
github.com/gin-gonic/gin v1.12.0
github.com/go-git/go-git/v5 v5.19.1
github.com/mattn/go-sqlite3 v1.14.24
github.com/go-sql-driver/mysql v1.10.0
github.com/joho/godotenv v1.5.1
github.com/sashabaranov/go-openai v1.41.2
golang.org/x/crypto v0.50.0
)
require (
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/ProtonMail/go-crypto v1.1.6 // indirect
github.com/bytedance/gopkg v0.1.3 // indirect