Skip to content
This repository has been archived by the owner on Jun 28, 2018. It is now read-only.

Commit

Permalink
add NewWithDatabaseInstance example
Browse files Browse the repository at this point in the history
  • Loading branch information
mattes committed Feb 15, 2017
1 parent 3feee59 commit 53630f5
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,26 @@ func main() {
}
```

Want to use an existing database client?

```go
import (
"database/sql"
_ "github.com/lib/pq"
"github.com/mattes/migrate/migrate"
"github.com/mattes/migrate/database/postgres"
)

func main() {
db, err := sql.Open("postgres", "postgres://localhost:5432/database?sslmode=enable")
driver, err := postgres.WithInstance(db, &postgres.Config{})
m, err := migrate.NewWithDatabaseInstance(
"file:///migrations",
"postgres", driver)
m.Steps(2)
}
```

## Migration files

Each migration has an up and down migration. [Why?](FAQ.md#why-two-separate-files-up-and-down-for-a-migration)
Expand Down

0 comments on commit 53630f5

Please sign in to comment.