up remove db tou rebuild

This commit is contained in:
julien 2025-06-19 17:20:58 +02:00
parent a1955c6ced
commit 809ed29858
2 changed files with 9 additions and 17 deletions

View File

@ -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:

View File

@ -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
}