[Feature Request] Partial indexes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- sql, typescript
- Domain
- databases
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- TypeScript
- Stars
- 2.9k
- Forks
- 157
- Avg merge
- 11h 42m
- Merged PRs (30d)
- 20
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from zenstackhq/zenstack
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
zenstackhq/zenstack#2873 ·
Maintainers usually reply within 1 day
-
runtime
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
zenstackhq/zenstack#2868 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
zenstackhq/zenstack#2694 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
zenstackhq/zenstack#2659 · 2 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
zenstackhq/zenstack#2542 · 1 comment ·
Maintainers usually reply within 1 day
All issues in zenstackhq/zenstack
Similar issues
-
nextjs-tracking
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
cloudflare/vinext#3887 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
apache/rocketmq-dashboard#6331 ·
Maintainers usually reply within 5 days
-
bug cache clinical-safety P1-critical
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
juspay/blend-design-system#1788 ·
Maintainers usually reply within 1 day
-
[Analytics] Add Focus Time-Block Efficiency Ratio Calculator in src/lib/focus/efficiency-ratio.tsOpenanalytics beginner friendly community contributions-welcome enhancement good first issue hacktoberfest help wanted up-for-grabs
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day