Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@clerk/elements": "^0.23.32",
"@clerk/nextjs": "^6.20.2",
"@clerk/themes": "^2.2.49",
"@google/generative-ai": "^0.24.1",
"@hookform/resolvers": "^5.0.1",
"@mdx-js/loader": "^3.1.0",
"@mdx-js/react": "^3.1.0",
Expand Down
21 changes: 21 additions & 0 deletions prisma/migrations/20260117000000_add_vector_search/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- CreateExtension
CREATE EXTENSION IF NOT EXISTS vector;

-- CreateTable
CREATE TABLE player_embeddings (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
player_id UUID NOT NULL UNIQUE REFERENCES players(id) ON DELETE CASCADE,
embedding vector(768) NOT NULL,
embedding_text TEXT NOT NULL,
created_at TIMESTAMP(6) DEFAULT NOW(),
updated_at TIMESTAMP(6) DEFAULT NOW()
);

-- CreateIndex
CREATE INDEX player_embeddings_player_id_idx ON player_embeddings(player_id);

-- CreateIndex (IVFFlat index for fast similarity search)
-- Note: For production, adjust the 'lists' parameter based on your data size
-- Rule of thumb: lists = sqrt(number_of_rows), minimum 1
CREATE INDEX player_embeddings_vector_idx ON player_embeddings
USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100);
19 changes: 19 additions & 0 deletions prisma/migrations/20260117093011_/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
Warnings:

- Made the column `created_at` on table `player_embeddings` required. This step will fail if there are existing NULL values in that column.
- Made the column `updated_at` on table `player_embeddings` required. This step will fail if there are existing NULL values in that column.

*/
-- DropForeignKey
ALTER TABLE "player_embeddings" DROP CONSTRAINT "player_embeddings_player_id_fkey";

-- DropIndex
DROP INDEX "player_embeddings_vector_idx";

-- AlterTable
ALTER TABLE "player_embeddings" ALTER COLUMN "created_at" SET NOT NULL,
ALTER COLUMN "updated_at" SET NOT NULL;

-- AddForeignKey
ALTER TABLE "player_embeddings" ADD CONSTRAINT "player_embeddings_player_id_fkey" FOREIGN KEY ("player_id") REFERENCES "players"("id") ON DELETE CASCADE ON UPDATE CASCADE;
17 changes: 17 additions & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ model Player {
favorited_by CoachFavorite[]
combine_registrations CombineRegistration[]
Conversation Conversation[]
embedding PlayerEmbedding?
game_profiles PlayerGameProfile[]
league_participations PlayerLeague[]
performance_stats PlayerPerformanceStats[]
Expand All @@ -59,6 +60,22 @@ model Player {
@@map("players")
}

/// Player embeddings for AI-powered semantic search
/// Note: The 'embedding' field is a vector(768) type managed via raw SQL
/// Prisma doesn't natively support pgvector, so we use Unsupported type
model PlayerEmbedding {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
player_id String @unique @db.Uuid
embedding Unsupported("vector(768)")
embedding_text String
created_at DateTime @default(now()) @db.Timestamp(6)
updated_at DateTime @default(now()) @db.Timestamp(6)
player Player @relation(fields: [player_id], references: [id], onDelete: Cascade)

@@index([player_id])
@@map("player_embeddings")
}

/// Coaches table with Clerk integration
model Coach {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
Expand Down
Loading