Skip to content

Feature: allow to infer logical links between tables - #28

Merged
denchenko merged 5 commits into
holydocs:mainfrom
ashumkin:feature/infer-logical-lines
Aug 5, 2026
Merged

Feature: allow to infer logical links between tables#28
denchenko merged 5 commits into
holydocs:mainfrom
ashumkin:feature/infer-logical-lines

Conversation

@ashumkin

@ashumkin ashumkin commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This PR adds logical-reference support for schemas whose intended
relationships are not completely represented by database foreign keys.

  • Adds --add-logical-references to infer references from <table>_id source
    columns. Inference is opt-in, stays within the same schema qualifier, supports
    common singular/plural table names, skips ambiguous matches, and never replaces
    an existing database or configured reference.

  • Adds --logical-references-file for explicitly declared YAML mappings. Each
    mapping identifies full source and target table-column endpoints, is validated
    against the extracted schema, and is applied after --skip-tables but before
    optional automatic inference. Invalid endpoints or conflicting targets fail the
    command without partially changing the schema; exact duplicate mappings are
    ignored.

  • Adds an optional name field to logical references. Inferred links default to
    logical <source-column>, while YAML mappings may supply a descriptive label.
    Names are exposed in JSON and rendered as relationship labels in D2, PlantUML,
    and Mermaid; unnamed references retain their existing output labels.

  • Documents the YAML format and naming behavior, provides a copyable example,
    and updates schema and renderer golden-test coverage.

    P.S. Yes, these are "AI assisted" changes ))

Infer references from <table>_id columns when --add-logical-references is
enabled. Match qualified tables within their schema, support singular and
plural table names, preserve explicit references, and skip ambiguous targets.

Cover logical reference inference, skipped tables, ordering, and idempotency.
Load explicit YAML mappings through --logical-references-file and apply them
before optional column-name inference. Validate all configured endpoints,
reject conflicting targets without partial changes, and ignore exact duplicates.

Expose parsing and schema-application APIs, document the file format with an
example, and cover YAML decoding and reference validation behavior.
Add optional reference names to the schema and YAML mappings. Name inferred
references as "logical <column>" and render names as diagram relationship
labels while retaining existing labels for unnamed references.

Document the naming behavior and update target golden fixtures and tests.
@ashumkin ashumkin changed the title Feature/infer logical lines Feature: allow to infer logical links between tables Aug 4, 2026
Comment thread README.md
Comment thread dberd.go
Recognize common -es plural suffixes when deriving singular table aliases,
including doubled-z plurals. Cover address, box, dish, quiz, and watch
logical-reference inference with regression tests.
@denchenko
denchenko merged commit e031312 into holydocs:main Aug 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants