Last active
August 1, 2019 05:50
-
-
Save kamal-kambe/11416f70a610b0fe6c2c3b355025277d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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