title: prisma introspect generate invalid model
body: <p>Prisma version         : ^2.26.0</p>
  <p>Prisma/client          : ^2.26.0</p>
  <p>@relation error msg in : Error parsing attribute &quot;@relation&quot;: The type of the field <code>userId</code> in the model <code>posts</code> is not matching the type of the referenced field <code>id</code> in model <code>users</code>.</p>
  <hr />
  <p>Why prisma created invalid model or something wrong with my code after i run <em><strong>npx prisma introspect</strong></em>?</p>
  <p>It cause cannot to enter the <strong>prisma studio</strong> since those error in my code.</p>
  <p>Any solution or thought could share to make me know better for this?</p>
  <p>Below is my sql:</p>
  <pre><code>-- Create a custom type
  CREATE TYPE &quot;user_role_enum&quot; AS ENUM ('user', 'admin', 'superadmin');
  
  -- Create a table
  CREATE TABLE &quot;users&quot;(
      &quot;id&quot; BIGSERIAL PRIMARY KEY NOT NULL,
      &quot;name&quot; VARCHAR(255) NOT NULL,
      &quot;email&quot; VARCHAR(255) UNIQUE NOT NULL,
      &quot;role&quot; user_role_enum NOT NULL DEFAULT('user')
  );
  
  -- Create a table
  CREATE TABLE &quot;posts&quot;(
      &quot;id&quot; BIGSERIAL PRIMARY KEY NOT NULL,
      &quot;title&quot; VARCHAR(255) NOT NULL,
      &quot;body&quot; TEXT,
      &quot;userId&quot; INTEGER NOT NULL,
      FOREIGN KEY (&quot;userId&quot;) REFERENCES &quot;users&quot;(&quot;id&quot;)
  );
  
  -- Create data
  INSERT INTO &quot;users&quot; (&quot;name&quot;, &quot;email&quot;, &quot;role&quot;)
  VALUES('John Doe', 'john@email.com', 'admin'),
  ('jane Doe', 'jane@email.com', 'admin'),
  ('Ahmed Hadjou', 'ahmed@hadjou.com', 'user');
  
  INSERT INTO &quot;posts&quot; (&quot;title&quot;, &quot;body&quot;, &quot;userId&quot;)
  VALUES('Hello World!!', 'Hey guys, I see a rainbow through this prisma :D', 1),
  ('So do I', 'It looks cooool!!!', 2),
  ('It does', 'Yeahhh', 1);
  
  </code></pre>
  <p>Generate for model from prisma introspect</p>
  <pre><code>
  model posts {
    id     BigInt  @id @default(autoincrement())
    title  String  @db.VarChar(255)
    body   String?
    userId Int
    users  users   @relation(fields: [userId], references: [id]) // Error parsing attribute &quot;@relation&quot;: The type of the field `userId` in the model `posts` is not matching the type of the referenced field `id` in model `users`.
  }
  
  model users {
    id    BigInt         @id @default(autoincrement())
    name  String         @db.VarChar(255)
    email String         @unique @db.VarChar(255)
    role  user_role_enum @default(user)
    posts posts[] // error in here
  }
  
  enum user_role_enum {
    user
    admin
    superadmin
  }
  </code></pre>