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

Postgres custom schema flag in url #4

Closed
mattes opened this issue Aug 13, 2014 · 4 comments
Closed

Postgres custom schema flag in url #4

mattes opened this issue Aug 13, 2014 · 4 comments

Comments

@mattes
Copy link
Owner

mattes commented Aug 13, 2014

# TODO: thinking about adding some custom flag to allow migration within schemas:
-url="postgres://user@host:port/database?schema=name" 
@abourget
Copy link

afaik, the pq driver allows you to set search_path through the URL, so this would apply to the next CREATE TABLE statements. Would that be sufficient for your needs ?

I haven't tested that yet though, just a suggestion.

@mattes
Copy link
Owner Author

mattes commented Apr 27, 2015

that would be cool. do you have a link to a reference?

@abourget
Copy link

http://godoc.org/github.com/lib/pq :)

Search the page for "search_path".. it's in there, but very subtle.

@adrienkohlbecker
Copy link

Hi,

For future developers stumbling on this issue while searching for a way to specify a schema, here is the syntax you have to use in the url options= -c search_path=my_schema which should be url-encoded as:

postgres://postgres:password@db:5432/my_db?options=+-c+search_path%3Dmy_schema

Note that the schema should already exist, and cannot be created via a migration.

For reference: https://github.com/lib/pq/blob/165a3529e799da61ab10faed1fabff3662d6193f/conn_test.go#L1341

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants