Refactor code
This commit is contained in:
parent
4c3f095109
commit
db6f98ba79
3 changed files with 17 additions and 26 deletions
29
migrate.go
29
migrate.go
|
|
@ -1,29 +0,0 @@
|
|||
package cgnolink
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/jackc/pgx/v4/pgxpool"
|
||||
"github.com/jackc/tern/migrate"
|
||||
)
|
||||
|
||||
func Migrate(pool *pgxpool.Pool) error {
|
||||
conn, err := pool.Acquire(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
migrator, err := migrate.NewMigrator(context.Background(), conn.Conn(), "schema_version")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = migrator.LoadMigrations("./migrations"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = migrator.Migrate(context.Background()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue