Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database Schema other than public #501

Closed
RVijay007 opened this issue Jun 1, 2018 · 4 comments
Closed

Database Schema other than public #501

RVijay007 opened this issue Jun 1, 2018 · 4 comments
Assignees
Labels
question Further information is requested

Comments

@RVijay007
Copy link

RVijay007 commented Jun 1, 2018

Hi, I'm using Vapor 3 to build a swift server that connects to an existing db within our organization. I've read the docs on how to connect to an existing database, but I'm still unclear on how to hook up Models to a specific schema. It seems to always use the public db schema; how can I use a schema other than public?

We use Postgres as our database.

@0xTim
Copy link
Member

0xTim commented Jun 2, 2018

If you configure your Postgres DB as normal in Vapor and then set the defaultDatabase property on the model it should work. (Also, don’t use a migration)

Details here https://forums.swift.org/t/new-to-swift-and-vapor-returning-data-from-mysql/13088

@RVijay007
Copy link
Author

RVijay007 commented Jun 2, 2018

I do that with a test db, but it is picking up only tables made in the public schema, and I'm not sure how to get it to use one of our other schema groupings instead. The database is going to be the same both ways, so I'm not sure why changing defaultDatabase is going to do anything. I'm looking for configuration of the schema parameter, such as when we write SQL queries:

SELECT
*
FROM
<schema>.<table>

I see that Models map to Tables, and the connection contains the database information, but what holds the schema information that can be configured dynamically (not static).

@fwgreen
Copy link

fwgreen commented Jun 5, 2018

@RVijay007 This issue is driver related and is finally (hopefully) being addressed.

@tanner0101
Copy link
Member

tanner0101 commented Jun 22, 2018

Closing here in favor of vapor/postgres-kit#9. There are a couple of good workarounds there in the interim.

@tanner0101 tanner0101 added the question Further information is requested label Jun 22, 2018
@tanner0101 tanner0101 self-assigned this Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants