Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[Feature Request] Partial indexes

Đang mở
#2,467 1 bình luận 4 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
15/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
sql, typescript
Lĩnh vực
databases

Hướng nghiên cứu

The desired syntax is spelled out in the request, but no file or entry point is named, so start by finding where ZModel parses and validates @@index/@@unique attributes and follow the path to where the Prisma schema and migrations are generated. A working result means the where filter on @@index/@@unique survives parsing and validation and shows up in the emitted Prisma schema. This is a cross-cutting language-design change touching the parser, validator and generators, and the one comment thread has not settled the design, so it is not a starting point for a first contribution.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Is your feature request related to a problem? Please describe.
Currently, it is not possible to describe partial indexes/unique constraint in the model itself, requiring external sql migration file.

This feature would allow for unique email for accounts that are active for example, or index only records created after a certain date, index active tasks only or allow for better soft deletion flexibility.

Describe the solution you'd like

model User {
  id        String   @id
  accountId String
  status    String
  email     String
  deletedAt DateTime?

  // Unique active emails per account (exclude soft-deleted)
  @@unique([accountId, email], where: { deletedAt: null })

  // Index only active or pending account
  @@index([accountId, status], where: { status: { in: ["pending", "active"] } })

  // Sparse index, only index rows where field is non-null
  @@index([accountId, email], where: { email: { not: null } })
}

Additional context
Add any other context or screenshots about the feature request here.

Ngôn ngữ chính
TypeScript
Star
2.9k
Fork
157
Merge trung bình
11 giờ 42 phút
Pull request đã merge (30 ngày)
20

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của zenstackhq/zenstack

Tất cả issue của zenstackhq/zenstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.