Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(setup): Use *pg.DB.CreateTable for a consistent interface #10

Merged
merged 1 commit into from
Aug 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(setup): Use *pg.DB.CreateTable for a consistent interface
  • Loading branch information
Robin Joseph committed Aug 24, 2018
commit 6f9e8ae17a789f06eee38ed188e7295b1c3fa3d3
12 changes: 7 additions & 5 deletions setup.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package migrations

import "github.com/go-pg/pg/orm"
import (
"github.com/go-pg/pg"
"github.com/go-pg/pg/orm"
)

func ensureMigrationTables(db orm.DB) error {
func ensureMigrationTables(db *pg.DB) error {
exists, err := checkIfTableExists("migrations", db)
if err != nil {
return err
Expand Down Expand Up @@ -52,8 +55,7 @@ func checkIfTableExists(name string, db orm.DB) (bool, error) {
return count > 0, nil
}

func createTable(model interface{}, db orm.DB) error {
func createTable(model interface{}, db *pg.DB) error {
opts := orm.CreateTableOptions{IfNotExists: true}
_, err := orm.CreateTable(db, model, &opts)
return err
return db.CreateTable(model, &opts)
}