diesel does not generate schema when using postgres schema

Created on 20 Jun 2019  路  2Comments  路  Source: diesel-rs/diesel

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.

Most helpful comment

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/

All 2 comments

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.

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/

Was this page helpful?
0 / 5 - 0 ratings