Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- db_models "driverbase/app/models"
- "github.com/go-pg/migrations"
- "github.com/go-pg/pg"
- "github.com/go-pg/pg/orm"
- )
- func init() {
- migrations.Register(func(db migrations.DB) error {
- // Get host, port, database, username, password etc from somewhere
- db = pg.Connect(&pg.Options{
- Addr: fmt.Sprintf("%s:%s", host, port),
- Database: database,
- User: username,
- Password: password,
- })
- err = db.CreateTable(&db_models.VehicleTires{}, &orm.CreateTableOptions{
- FKConstraints: true,
- })
- if err != nil {
- return err
- }
- }, func(db migrations.DB) error {
- // ignore for now
- return nil
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement