Skip to content

feat: Supabase pgvector tables, HNSW indexes, RPC functions 추가 - #13

Merged
kelly0819 merged 9 commits into
developfrom
feature/db-pgvector-migrations
May 27, 2026
Merged

feat: Supabase pgvector tables, HNSW indexes, RPC functions 추가#13
kelly0819 merged 9 commits into
developfrom
feature/db-pgvector-migrations

Conversation

@harim789

Copy link
Copy Markdown
Collaborator

📌 관련 이슈

closes #6

📝 작업 내용

벡터DB 스키마 설계에 정의된 벡터 검색 인프라를 Supabase에 구축.

테이블 3종 + HNSW 인덱스

  • product_embeddings(feature_vec vector(1024)) — HNSW cosine
  • review_embeddings(embedding vector(1024)) — HNSW + product_id 인덱스
  • user_context_rags(embedding vector(1024)) — HNSW + (user_id, category, created_at) 인덱스

RPC 함수 4종 (service_role 권한)

  • match_products(query, category, count, exclude_ids) — discovery 후보 검색
  • match_alternatives(base_product_id, count, exclude_ids) — 대체 상품 검색
  • match_reviews(query, product_id, count) — review_score 계산
  • match_user_contexts(user_id, query, category, count) — RAG 검색

Supabase Dashboard SQL Editor에서 001~008 순서대로 적용. 적용 후 더미 쿼리로 동작 확인:

SELECT * FROM match_products(
  array_fill(0.1::float4, ARRAY[1024])::vector,
  NULL, 5, '{}'::uuid[]
);
-- 데이터 없으면 빈 결과 반환 (정상)

📁 변경 파일

  • AI/db/migrations/001_enable_pgvector.sql
  • AI/db/migrations/002_create_product_embeddings.sql
  • AI/db/migrations/003_create_review_embeddings.sql
  • AI/db/migrations/004_create_user_context_rags.sql
  • AI/db/migrations/005_rpc_match_products.sql
  • AI/db/migrations/006_rpc_match_alternatives.sql
  • AI/db/migrations/007_rpc_match_reviews.sql
  • AI/db/migrations/008_rpc_match_user_contexts.sql
  • AI/scripts/apply_migrations.py

✅ 체크리스트

  • 테스트 통과 확인 — SELECT proname FROM pg_proc WHERE proname LIKE 'match_%'; → 4건 확인
  • 담당 범위 외 파일 수정 없음
  • 코드 주석 확인 — 각 SQL 파일 상단에 목적·의존 테이블 주석 포함

@harim789 harim789 self-assigned this May 26, 2026
@harim789 harim789 added the feat 새로운 기능 추가 label May 26, 2026
@harim789 harim789 linked an issue May 26, 2026 that may be closed by this pull request
20 tasks
@harim789 harim789 changed the title feat: Supabase pgvector tables, indexes, and RPC functions feat: Supabase pgvector tables, HNSW indexes, RPC functions 추가 May 26, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@kelly0819 kelly0819 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿

@kelly0819
kelly0819 merged commit 7a19cd2 into develop May 27, 2026
1 check failed
@harim789
harim789 deleted the feature/db-pgvector-migrations branch May 27, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Supabase pgvector tables, HNSW indexes, RPC functions 추가

3 participants