How to resolve this error: Prisma Migration Error

I am trying to run migration using Prisma, but after running the command I got this error.

Error: P3006

Migration `20230622214122_adding_vector_store_to_db` failed to apply cleanly to the shadow database. 
Error:
db error: ERROR: type "vector" does not exist
   0: sql_schema_connector::validate_migrations
           with namespaces=None
             at schema-engine/connectors/sql-schema-connector/src/lib.rs:312
   1: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:270

This is what my Prisma.schema looks like:

datasource db {
  provider          = "postgresql"
  url               = env("DATABASE_URL")
  shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
  directUrl         = env("DIRECT_URL")
  extensions        = [vector]
}

and a sample model looks like this:

model Document {
  id          Int                       @id @default(autoincrement())
  embedding   Unsupported("vector(3)")?
  EmailTool   EmailTool?                @relation(fields: [emailToolId], references: [id])
  emailToolId String?
}

My Prisma setup is correct as per guides from the docs. Can you help resolve this?

Hey @ChrisB007 :wave:

You don’t need to specify the shadowDatabaseUrl anymore. Do you mind deleting the database you manually created and trying again?

Did you also enable the postgresqlExtensions preview feature?

Hello Mahmoud,
Thanks for the prompt response. Yes I used shadowDatabaseUrl and postgresqlExtensions preview feature. Please check out my model in my Prisma.schemafile below:

datasource db {
  provider          = "postgresql"
  url               = env("DATABASE_URL")
  shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
  directUrl         = env("DIRECT_URL")
}

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions"]
}

model Account {
  id                String  @id @default(cuid())
  userId            String
  type              String
  provider          String
  providerAccountId String
  refresh_token     String? @db.Text
  access_token      String? @db.Text
  expires_at        Int?
  token_type        String?
  scope             String?
  id_token          String? @db.Text
  session_state     String?

  user User @relation(fields: [userId], references: [id], onDelete: Cascade)

  @@unique([provider, providerAccountId])
}

model Session {
  id           String   @id @default(cuid())
  sessionToken String   @unique
  userId       String
  expires      DateTime
  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model User {
  id            String    @id @default(cuid())
  userId        String?   @unique
  name          String? //Social Auth Login - revisit later
  externalId    String?
  Username      String?
  firstName     String?
  profileImage  String?
  emailVerified String?
  role          String?
  image         String?
  lastName      String?
  email         String    @unique
  // emailtool     EmailTool[]
  createdAt     DateTime  @default(now())
  updatedAt     DateTime  @updatedAt
  Accounts      Account[]
  Sessions      Session[]
}

So you are saying to remove the shadowDatabaseUrl?

So, I just created a brand new database, configured .env and prisma.schema file with the connection strings, removed the shadowDatabase from .env as well as prisma.schema file and still got the error both when I commented out and uncommented out the previewFeatures = ["postgresqlExtensions"]:

Error: P3006

Migration `20230622214122_adding_vector_store_to_db` failed to apply cleanly to the shadow database. 
Error:
db error: ERROR: type "vector" does not exist
   0: sql_schema_connector::validate_migrations
           with namespaces=None
             at schema-engine/connectors/sql-schema-connector/src/lib.rs:312
   1: schema_core::state::DevDiagnostic
             at schema-engine/core/src/state.rs:270

Any further suggestion?

Have you enabled the extension for your database?

You can do so by running CREATE EXTENSION vector; in the Neon SQL editor

Hello Mahmoud,
Thanks again for the response. I did run the CREATE EXTENSION vector; as suggested, and the issue still persists, please checkout the Loom cast: [Loom | Free Screen & Video Recording Software | Loom] to see if something is missing.
Also, reading up on the neon docs for connecting - You mentioned above that we don’t need to use the shadowDatabaseUrl any longer, but I have this still on there:

// prisma/schema.prisma
datasource db {
  provider = "postgresql"
  url  	= env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
  // If you want to use Prisma Migrate, you will need to manually create a shadow database
  // https://neon.tech/docs/guides/prisma-migrate#configure-a-shadow-database-for-prisma-migrate
  // make sure to append ?connect_timeout=10 to the connection string
  // shadowDatabaseUrl = env(“SHADOW_DATABASE_URL”)
}

Please advice if this might be the reason of the issues I’m facing. Please note that the frontend is deployed on Vercel.