Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ You can use the [Pact Broker Docker image][docker] or [Terraform on AWS][terrafo
* Copy the [pact\_broker](https://github.com/DiUS/pact_broker-docker/tree/master/pact_broker) directory from the Pact Broker Docker project. This will have the recommended settings for database connections, logging, basic auth etc. Note that the Docker image uses Phusion Passenger as the web application server in front of the Pact Broker Ruby application, which is the recommended set up if you are not using a containerized solution.
* Modify the config.ru and Gemfile as desired (eg. choose database driver gem, set your database credentials. Use the "pg" gem for Postgres)
* example Sequel configuration for postgres `{ adapter: "postgres", database: "pact_broker", username: 'pact_broker', password: 'pact_broker', :encoding => 'utf8' }`
* If you need to use a custom PostgreSQL schema instead of the default `public` schema, add the `search_path` parameter: `{ adapter: "postgres", database: "pact_broker", username: 'pact_broker', password: 'pact_broker', :encoding => 'utf8', :search_path => 'my_custom_schema' }`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why search_path, and not schema here? same for other places it applies across the other files

* Please ensure you use `encoding: 'utf8'` in your Sequel options to avoid encoding issues.
* For production usage, use a web application server like [Phusion Passenger](https://www.phusionpassenger.com) or [Nginx](http://nginx.org/) to serve the Pact Broker application. You'll need to read up on the documentation for these yourself as it is beyond the scope of this documentation. See the [wiki][reverse-proxy-docs] for instructions on using a reverse proxy with SSL.
* Ensure the environment variable `RACK_ENV` is set to `production`.
Expand Down
3 changes: 2 additions & 1 deletion config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test:
postgres:
<<: *default
adapter: postgres
search_path: public
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we shouldn't need to explicitly specify here, if it defaults to public

docker_postgres:
adapter: postgres
database: postgres
Expand Down Expand Up @@ -76,4 +77,4 @@ development:
production:
default:
<<: *default
adapter: postgres
adapter: postgres
9 changes: 9 additions & 0 deletions docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ penalty, so consider increasing this timeout if building a frequently accessed s
**Allowed values:** -1 or any positive integer.<br/>
**More information:** https://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/connection_validator_rb.html<br/>

### database_schema

The PostgreSQL schema to use. If you need to use a schema other than the default public schema, set this value.

**Environment variable name:** `PACT_BROKER_DATABASE_SCHEMA`<br/>
**YAML configuration key name:** `database_schema`<br/>
**Default:** `public`<br/>
**Allowed values:** A valid PostgreSQL schema name<br/>

<br/>

## Authentication and authorization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def self.included(anyway_config)
database_port: nil,
database_url: nil,
database_sslmode: nil,
database_schema: "public", # Default to public schema
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does a default value need to be provided here? If one isn't provided, surely it defaults to public to preserve existing behaviour. can this attr be set to nil?

sql_log_level: :none,
sql_log_warn_duration: 5,
sql_enable_caller_logging: false,
Expand Down Expand Up @@ -104,7 +105,8 @@ def database_configuration_from_parts
password: database_password,
host: database_host,
database: database_name,
port: database_port
port: database_port,
search_path: database_schema
}.compact
end
private :database_credentials
Expand All @@ -118,6 +120,7 @@ def database_configuration_from_url
host: uri.host,
database: uri.path.sub(/^\//, ""),
port: uri.port&.to_i,
search_path: database_schema
}.compact
end
private :database_configuration_from_url
Expand Down