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