Skip to content

Instantly share code, notes, and snippets.

@kamal-kambe
Last active August 1, 2019 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamal-kambe/11416f70a610b0fe6c2c3b355025277d to your computer and use it in GitHub Desktop.
Save kamal-kambe/11416f70a610b0fe6c2c3b355025277d to your computer and use it in GitHub Desktop.
package provider
import (
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
"sample-app/model"
"sample-app/util"
)
var models = []interface{}{
&model.Building{},
&model.BuildingLevel{},
&model.Quest{},
}
func InitDB() (db *gorm.DB, err error) {
db, err = gorm.Open("postgres", "user=test password=test dbname=sample_app sslmode=disable")
if err != nil {
return
}
db.AutoMigrate(models...)
util.Register(models...)
return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment