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

diesel does not generate schema when using postgres schema #2096

Closed
onsails opened this issue Jun 20, 2019 · 3 comments
Closed

diesel does not generate schema when using postgres schema #2096

onsails opened this issue Jun 20, 2019 · 3 comments

Comments

@onsails
Copy link

onsails commented Jun 20, 2019

Setup

Versions

  • Rust: 1.35.0
  • Diesel: 1.4.2
  • Database: PostgreSQL 11
  • Operating System macOS

Feature Flags

  • diesel: postgres, chrono

Problem Description

When I use DATABASE_URL like this: DATABASE_URL="postgres://user@localhost/mydb" #?options=-c search_path%3Dtest" both diesel print-schema and diesel migration run generate empty schema.rs.
When I use default postgres schema (without search_path) it generates normal schema.

@weiznich
Copy link
Member

We do not parse the database url, we just pass it down to libpq.
For diesel print-schema just use the -s flag to specify the schema, for migrations just specify the target schema as part of the migration.

@192709
Copy link

192709 commented Aug 7, 2019

Dear Weiznich, your solution wrt. print-schema is clear to me, however, what do you mean with 'just specify the target schema as part of the migration?" I do not get it - can you provide an example?

EDIT: After searching around I found it. In the diesel.toml add a new line below the print_schema section:
...
[print_schema]
file = "src/schema.rs"
schema = "MY-SCHEMA"

Details are here: http://diesel.rs/guides/configuring-diesel-cli/

@matrixmosaic
Copy link

Dear Weiznich, your solution wrt. print-schema is clear to me, however, what do you mean with 'just specify the target schema as part of the migration?" I do not get it - can you provide an example?

EDIT: After searching around I found it. In the diesel.toml add a new line below the print_schema section: ... [print_schema] file = "src/schema.rs" schema = "MY-SCHEMA"

Details are here: http://diesel.rs/guides/configuring-diesel-cli/

@192709 How to specify multiple schemas in this schema attribute (I want to have several models specified into different schema according to their domain categories).

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

No branches or pull requests

4 participants