diff --git a/docker-compose.yml b/docker-compose.yml index adcc1b6..e388f49 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,7 @@ services: volumes: - .:/app - shelfly_upload:/app/upload - - ./shelfly_db.db:/app/shelfly_db.db + - shelfly_db:/app/shelfly_db dns: - 8.8.8.8 - 1.1.1.1 @@ -33,3 +33,4 @@ services: volumes: shelfly_upload: + shelfly_db: diff --git a/internal/db/db.go b/internal/db/db.go index 27711f2..10964ed 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -10,20 +10,13 @@ import ( "gorm.io/gorm" ) -func InitDB()*gorm.DB { - - dbName:="shelfly_db.db" - // Ouvre une connexion à la base de données - //db, err := gorm.Open(sqlite.Open(dbName), &gorm.Config{}) - db, err := gorm.Open(sqlite.Open(dbName), &gorm.Config{ - //Logger: logger.Default.LogMode(logger.Info), // pour voir les types SQL utilisés -}) +func InitDB() *gorm.DB { + dbName := "/app/shelfly_db/shelfly_db.db" + db, err := gorm.Open(sqlite.Open(dbName), &gorm.Config{}) if err != nil { - panic("failed to connect database") + panic("failed to connect database") } - //db.Migrator().DropTable(&download.DownloadJob{}) // ⚠️ temporaire - // Migrate the schema db.AutoMigrate( &models.User{}, &models.Files{}, @@ -42,14 +35,12 @@ func InitDB()*gorm.DB { &debridlink.Torrent{}, &debridlink.DebridAccount{}, &download.DownloadJob{}, - - ) - fmt.Println("Connexion réussie à MySQL !") - fmt.Println("Auto migration completed") + fmt.Println("Connexion réussie à SQLite !") + fmt.Println("Auto migration terminée") return db - } +