Skip to content

Partial index predicates not stripped when partialIndexes preview feature is disabled, causing unnecessary DROP INDEX migrations #5781

@jay-l-e-e

Description

@jay-l-e-e

Related issue

prisma/prisma#29220

Problem

Since partial index support was added (PR #5749), the SQL schema describer always returns index predicates from the database regardless of whether the partialIndexes preview feature is enabled. When the feature is off:

  • Database schema (from describe_schema): index has predicate = Some("...")
  • Target schema (from PSL): index has predicate = None

The differ calls predicates_match(Some("..."), None) → returns false → the index is treated as changed → generates a needless DROP INDEX + CREATE INDEX on every schema_push / migrate dev, even when no schema changes were made.

This affects users who manually added partial indexes via custom SQL in migration files (the recommended workflow before partialIndexes existed) or directly in the database. Previously these indexes were invisible to the differ; now they cause drift on every invocation.

Expected behavior

When partialIndexes is not enabled, the schema engine should ignore index predicates entirely — both in the database schema and the target schema. Manually created partial indexes should be left untouched.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions