Hi, just moved to Prisma and its great!
Recently, we moved to Supabase in order to implement a vector store db.
Firstly, i tried create a schema like this:
generator client {
provider = "prisma-client-js"
previewFeatures = ["postgresqlExtensions"]
}
datasource db {
provider = "postgresql"
url = env("SUPABASE_CONNECTION_STRING")
extensions = [uuid_ossp(map: "uuid-ossp", schema: "extensions"), pgvector(map: "vector", schema: "public")]
}
...
model Document {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
pageContent String
workspaceId String
embeddings Unsupported("vector(1024)")?
workspace Workspace @relation(fields: [workspaceId], references: [id])
metadata DocumentMetadata?
chatId String?
chat Chat?
}
Which didn't passed the npx prisma migrate dev --name init command, causing:
Database error code: 42704
Database error:
ERROR: type "vector" does not exist
Position:
57 "id" TEXT NOT NULL,
58 "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
59 "updatedAt" TIMESTAMP(3) NOT NULL,
60 "pageContent" TEXT NOT NULL,
61 "workspaceId" TEXT NOT NULL,
62 "embeddings" vector(1024),
DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42704), message: "type \"vector\" does not exist", detail: None, hint: None, position: Some(Original(1597)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("parse_type.c"), line: Some(270), routine: Some("typenameType") }
But it does generated a sql migration file.
I've took that file and copy-paste it into Supabase query terminal - and it worked, by creating the appropriate tables.
Next, i run npx prisma generate to create the client.
Now, its time to do some queries/adding some vectors into the table.