28 lines
458 B
Go
28 lines
458 B
Go
package postgres
|
|
|
|
import (
|
|
"os"
|
|
|
|
"myschools.me/community/community-api/model"
|
|
)
|
|
|
|
func init() {
|
|
if os.Getenv("POSTGRES_INIT") != "true" {
|
|
return
|
|
}
|
|
|
|
db, err := newDB()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
if err := db.AutoMigrate(&model.User{}); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := db.AutoMigrate(&model.Premises{}); err != nil {
|
|
panic(err)
|
|
}
|
|
if err := db.AutoMigrate(&model.Application{}, &model.ApplicationMenu{}); err != nil {
|
|
panic(err)
|
|
}
|
|
}
|