Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
Postgres - Add x-schema-name URL Query support (golang-migrate#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-klein committed Nov 28, 2020
1 parent a53e6fc commit f8f6366
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions database/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
| URL Query | WithInstance Config | Description |
|------------|---------------------|-------------|
| `x-migrations-table` | `MigrationsTable` | Name of the migrations table |
| `x-schema-name` | `SchemaName` | Schema name of the migratations table |
| `x-statement-timeout` | `StatementTimeout` | Abort any statement that takes more than the specified number of milliseconds |
| `dbname` | `DatabaseName` | The name of the database to connect to |
| `search_path` | | This variable specifies the order in which schemas are searched when an object is referenced by a simple name with no schema specified. |
Expand Down
2 changes: 2 additions & 0 deletions database/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
}

migrationsTable := purl.Query().Get("x-migrations-table")
schemaName := purl.Query().Get("x-schema-name")
statementTimeoutString := purl.Query().Get("x-statement-timeout")
statementTimeout := 0
if statementTimeoutString != "" {
Expand All @@ -135,6 +136,7 @@ func (p *Postgres) Open(url string) (database.Driver, error) {
px, err := WithInstance(db, &Config{
DatabaseName: purl.Path,
MigrationsTable: migrationsTable,
SchemaName: schemaName,
StatementTimeout: time.Duration(statementTimeout) * time.Millisecond,
})

Expand Down

0 comments on commit f8f6366

Please sign in to comment.