Diesel: Cannot infer_schema! with Uuid type

Created on 18 Mar 2017  路  1Comment  路  Source: diesel-rs/diesel

Diesel version:

diesel = { version = "0.12.0", features = ["postgres"] }
diesel_codegen = { version = "0.12.0", features = ["postgres"] }

Rust: rustc 1.17.0-nightly (0aeb9c129 2017-03-15)

I have a User model with an UUID:

-- Your SQL goes here
CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  email VARCHAR NOT NULL,
  password TEXT NOT NULL,
)

The infer_schema! macro fails everytime however:

infer_schema!("dotenv:DATABASE_URL");
error[E0412]: cannot find type `Uuid` in this scope
 --> dutrack-lib/src/db/schema.rs:3:1
  |
3 | infer_schema!("dotenv:DATABASE_URL");
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope
  |
  = help: possible candidate is found in another module, you can import it into scope:
            `use uuid::Uuid;`
  = note: this error originates in a macro outside of the current crate

I tried importing Uuid into the scope in db/schema.rs but this didn't help either.

Most helpful comment

Nevermind, just saw that I need to add uuid to my features in the Cargo.toml.

>All comments

Nevermind, just saw that I need to add uuid to my features in the Cargo.toml.

Was this page helpful?
0 / 5 - 0 ratings