up remove db tou rebuild
This commit is contained in:
parent
a1955c6ced
commit
809ed29858
@ -12,7 +12,7 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- .:/app
|
- .:/app
|
||||||
- shelfly_upload:/app/upload
|
- shelfly_upload:/app/upload
|
||||||
- ./shelfly_db.db:/app/shelfly_db.db
|
- shelfly_db:/app/shelfly_db
|
||||||
dns:
|
dns:
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
@ -33,3 +33,4 @@ services:
|
|||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
shelfly_upload:
|
shelfly_upload:
|
||||||
|
shelfly_db:
|
||||||
|
|||||||
@ -11,19 +11,12 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func InitDB() *gorm.DB {
|
func InitDB() *gorm.DB {
|
||||||
|
dbName := "/app/shelfly_db/shelfly_db.db"
|
||||||
dbName:="shelfly_db.db"
|
db, err := gorm.Open(sqlite.Open(dbName), &gorm.Config{})
|
||||||
// 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
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("failed to connect database")
|
panic("failed to connect database")
|
||||||
}
|
}
|
||||||
//db.Migrator().DropTable(&download.DownloadJob{}) // ⚠️ temporaire
|
|
||||||
|
|
||||||
// Migrate the schema
|
|
||||||
db.AutoMigrate(
|
db.AutoMigrate(
|
||||||
&models.User{},
|
&models.User{},
|
||||||
&models.Files{},
|
&models.Files{},
|
||||||
@ -42,14 +35,12 @@ func InitDB()*gorm.DB {
|
|||||||
&debridlink.Torrent{},
|
&debridlink.Torrent{},
|
||||||
&debridlink.DebridAccount{},
|
&debridlink.DebridAccount{},
|
||||||
&download.DownloadJob{},
|
&download.DownloadJob{},
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
fmt.Println("Connexion réussie à MySQL !")
|
fmt.Println("Connexion réussie à SQLite !")
|
||||||
fmt.Println("Auto migration completed")
|
fmt.Println("Auto migration terminée")
|
||||||
return db
|
return db
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user