Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "fmt"
  5. db_models "driverbase/app/models"
  6. "github.com/go-pg/migrations"
  7. "github.com/go-pg/pg"
  8. "github.com/go-pg/pg/orm"
  9. )
  10.  
  11. func init() {
  12. migrations.Register(func(db migrations.DB) error {
  13. // Get host, port, database, username, password etc from somewhere
  14. db = pg.Connect(&pg.Options{
  15. Addr: fmt.Sprintf("%s:%s", host, port),
  16. Database: database,
  17. User: username,
  18. Password: password,
  19. })
  20.  
  21. err = db.CreateTable(&db_models.VehicleTires{}, &orm.CreateTableOptions{
  22. FKConstraints: true,
  23. })
  24.  
  25. if err != nil {
  26. return err
  27. }
  28. }, func(db migrations.DB) error {
  29. // ignore for now
  30. return nil
  31. })
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement