Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

[Feature Request] Partial indexes

Open
#2,467 1 comment 4 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from zenstackhq/zenstack

All issues in zenstackhq/zenstack

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.