package database import ( "log" "git.tovijaeschke.xyz/tovi/JumboPetstore/models" "gorm.io/driver/postgres" "gorm.io/gorm" ) const ( dbUrl = "postgres://postgres:@localhost:5432/petstore" ) var ( DB *gorm.DB ) func Init() { var ( err error ) DB, err = gorm.Open(postgres.Open(dbUrl), &gorm.Config{}) if err != nil { log.Fatalln(err) } DB.AutoMigrate(&models.PetCategory{}) DB.AutoMigrate(&models.PetTag{}) DB.AutoMigrate(&models.PetPhoto{}) DB.AutoMigrate(&models.Pet{}) }