Skip to content

Support required relation constraints in schema #2546

Description

@uriva

Problem

It would be useful if Instant schema could express that a relation is required, so application data can rely on that invariant being enforced by the database layer.

Today, even when an app models a one-to-one or one-to-many link as conceptually mandatory, the relation can still be unset. That means applications need to enforce the invariant entirely in application code and periodically audit or repair missing links.

Feature request

Add support for required relation constraints in the schema.

Examples of the kind of guarantees that would be helpful:

  • a one-link that must always be present
  • a relation with a minimum cardinality, such as at least one linked record
  • validation on writes so invalid states are rejected instead of silently accepted

Why this would help

This would make schema definitions more expressive and reduce a class of data-integrity bugs that are otherwise easy to introduce through alternate write paths, migrations, or manual/admin mutations.

Possible directions

Some possible designs:

  • schema-level required support for links
  • min / max cardinality constraints on relations
  • optional validation tooling that can both block invalid writes and report existing violations

Even a limited first version for required one-links would be very useful.

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