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.
 
 
 

36 lines
573 B

package database
import (
"log"
"git.tovijaeschke.xyz/tovi/personal_website/variables"
"gorm.io/gorm"
)
func updateDefaultSidebarLinks() {
var e error
for name, link := range variables.DefaultSidebarLinks {
e = AddSidebarLink(name, link)
if e != nil {
log.Fatal(e)
}
}
}
func MigrateDB() error {
var (
migrator gorm.Migrator
)
migrator = DB.Migrator()
if !migrator.HasTable(Post{}) {
migrator.CreateTable(&Post{})
}
if !migrator.HasTable(SidebarLink{}) {
migrator.CreateTable(&SidebarLink{})
updateDefaultSidebarLinks()
}
return nil
}