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.
 

46 lines
900 B

package database
import (
"log"
"git.tovijaeschke.xyz/tovi/SuddenImpactRecords/models"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
const dbUrl = "postgres://postgres:@localhost:5432/sudden_impact_records"
var (
DB *gorm.DB
)
func Init() {
var (
err error
)
log.Println("Initializing database...")
DB, err = gorm.Open(postgres.Open(dbUrl), &gorm.Config{})
if err != nil {
log.Fatalln(err)
}
log.Println("Running AutoMigrate on Post tables...")
// Post tables
DB.AutoMigrate(&models.PostImage{})
DB.AutoMigrate(&models.PostVideo{})
DB.AutoMigrate(&models.PostAudio{})
DB.AutoMigrate(&models.PostLink{})
DB.AutoMigrate(&models.Post{})
log.Println("Running AutoMigrate on Subscription tables...")
// Email subscription tables
DB.AutoMigrate(&models.SubscriptionEmailAttachment{})
DB.AutoMigrate(&models.SubscriptionEmail{})
DB.AutoMigrate(&models.Subscription{})
}