You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
500 B

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{})
}