fix(GAT-9245): Saving unresolvable linkages - #1748
Merged
Merged
Conversation
Make the linkage junction tables the complete source of truth for linkage data. Unresolvable free-text dataset references (raw url/pid/title) and publication DOIs are now stored as junction rows with a NULL target FK, so Gwdm2xHandler::afterRead() can reconstruct the full GWDM linkage section from SQL instead of a dual-source merge against the JSON blob. - migration: nullable target FKs + raw_url/raw_pid/raw_title/raw_doi columns - Gwdm2xHandler: store + reconstruct unresolved references - junction models: raw_* fillable Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
🎉 Great job! Your PR title follows the correct format. 🚀 |
equinoxmatt
approved these changes
Sep 28, 2026
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Screenshots (if relevant)
N/A
Describe your changes
Now that the linkage junction tables are the source of truth for GWDM 2.x linkages,
afterRead()rebuilds the linkage block from SQL alone. Previously, any reference extraction could not resolve at write time was dropped — so it survived only in the JSON blob and was lost on read:publicationsrow, orThis branch makes the junction tables the complete source of truth so those references are preserved, and adds a manual command to backfill/inspect existing data.
1. Preserve unresolved references (
Gwdm2xHandler+ migration2026_06_18_000001)dataset_version_target_id = NULL+raw_url/raw_pid/raw_title; unresolved DOIs withpublication_id = NULL+raw_doi(both FKs made nullable).afterRead()/getLinkages()reconstruct them (publications viaCOALESCE(publications.paper_doi, raw_doi)).NULL(blankToNull) on write and read: the GWDM schema allows nullurl/pid/titlebut rejects''(minLength/uri), so this prevents read-time validation failures. (Null itself is valid per the schema.)resolveUnresolvedDatasetLinkages) reused byafterRead()andgetLinkages().2.
app:reconcile-linkagescommand (manual ops tool — not auto-wired)--dry-runprints a drift report: a table of what is in the blob but missing from SQL, with a reason, plus a per-reason summary — and writes nothing. Reasons: no publication row, publication exists but not linked, linkage soft-deleted, unresolvable reference, dataset exists but not linked, target dataset not active.--dataset,--all-versions,--sync(inline via handler),--dry-run,--force,--chunk.Issue ticket link
https://hdruk.atlassian.net/browse/GAT-9245
Environment / Configuration changes (if applicable)
None. New artisan command is run manually; nothing dispatches it automatically.
Requires migrations being run?
Yes —
2026_06_18_000001_add_unresolved_linkage_columns(nullable target FKs +raw_url/raw_pid/raw_title/raw_doi). Existing rows predate the change; runphp artisan app:reconcile-linkages --dry-runto see drift, then without--dry-runto backfill.If not using the pre-push hook. Confirm tests pass:
pest tests/Feature/DatasetVersionLinkageTest.php— 12 passed.Tests added (authored by Claude, reviewed by the author):
test_unresolved_linkage_roundtrips_title_and_url_via_get_linkagestest_extract_linkages_reads_blob_not_stale_sql_overlaytest_reconcile_command_backfills_unresolved_publication_doitest_reconcile_dry_run_reports_drift_without_writingChecklist before requesting a review
MockExternalApis)LinkageExtraction)