Skip to content

Loader error for an enforced reference/relationship to a non-persisted (sourceless) target #250

Closed as not planned

Description

@dmealing

Follow-up from #248 (PR #249), design spec §9a.

After #248, an object that declares no source.* is correctly not persisted. But an @enforce'd identity.reference (or an enforced relationship FK) from a persisted entity to a sourceless target now produces divergent, silently-wrong downstream behavior:

  • migrate-ts silently skips the FK — the target has no table, so buildForeignKeys hits its existing if (!refTable) continue; and emits no constraint.
  • codegen-ts drizzle-schema.ts still emits a .references() against a table const that doesn't exist → broken generated code.

A physical foreign key needs a physical target. The right fix is a loader error — cross-port (all four loaders + a shared conformance fixture) — rejecting an enforced reference/relationship whose target declares no persistence source. This was deliberately out of scope for #248 (too big for a PATCH).

Ref: docs/superpowers/specs/2026-08-01-issue-248-persistability-from-source-design.md §9a.

Activity

  1. dmealing commented on Aug 2, 2026

    @dmealing
    MemberAuthor

    Closing — not tracking as a separate issue. This deferred item remains documented in the #248 design spec (docs/superpowers/specs/2026-08-01-issue-248-persistability-from-source-design.md §9) on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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