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.
 
 
 

37 lines
547 B

package Database
import (
"log"
"gorm.io/gorm"
"PersonalWebsite/Variables"
)
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
}