Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions internal/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"github.com/redis/go-redis/v9"
"go.uber.org/dig"
"google.golang.org/grpc"
"gorm.io/driver/mysql"

Check failure on line 32 in internal/container/container.go

View workflow job for this annotation

GitHub Actions / Format, vet, test, and build

no required module provides package gorm.io/driver/mysql; to add it:

Check failure on line 32 in internal/container/container.go

View workflow job for this annotation

GitHub Actions / Format, vet, test, and build

no required module provides package gorm.io/driver/mysql; to add it:

Check failure on line 32 in internal/container/container.go

View workflow job for this annotation

GitHub Actions / Format, vet, test, and build

no required module provides package gorm.io/driver/mysql; to add it:

Check failure on line 32 in internal/container/container.go

View workflow job for this annotation

GitHub Actions / Format, vet, test, and build

no required module provides package gorm.io/driver/mysql; to add it:
"gorm.io/driver/postgres"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
Expand Down Expand Up @@ -579,6 +580,32 @@
os.Getenv("DB_PORT"),
os.Getenv("DB_NAME"),
)
case "mysql":
dbPassword := os.Getenv("DB_PASSWORD")
encodedPassword := url.QueryEscape(dbPassword)
gormDSN := fmt.Sprintf(
"%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
os.Getenv("DB_USER"),
dbPassword,
os.Getenv("DB_HOST"),
os.Getenv("DB_PORT"),
os.Getenv("DB_NAME"),
)
dialector = mysql.Open(gormDSN)
migrateDSN = fmt.Sprintf(
"mysql://%s:%s@tcp(%s:%s)/%s",
os.Getenv("DB_USER"),
encodedPassword,
os.Getenv("DB_HOST"),
os.Getenv("DB_PORT"),
os.Getenv("DB_NAME"),
)
logger.Infof(context.Background(), "DB Config: user=%s host=%s port=%s dbname=%s",
os.Getenv("DB_USER"),
os.Getenv("DB_HOST"),
os.Getenv("DB_PORT"),
os.Getenv("DB_NAME"),
)
case "sqlite":
dbPath := os.Getenv("DB_PATH")
if dbPath == "" {
Expand Down Expand Up @@ -613,9 +640,9 @@
// different name (e.g., a wrapper dialect for managed PG) would silently
// fall back to the SQLite path, dropping the row-level X-lock. Catching
// the mismatch at startup is loud and inexpensive.
if name := db.Dialector.Name(); name != "postgres" && name != "sqlite" {
if name := db.Dialector.Name(); name != "postgres" && name != "sqlite" && name != "mysql" {
return nil, fmt.Errorf(
"unsupported gorm dialector %q; expected postgres or sqlite "+
"unsupported gorm dialector %q; expected postgres, mysql or sqlite "+
"(see vectorStoreService.isPostgres for impact)", name)
}

Expand Down
Loading