Add dois/doi_messages tables and data-access methods - #12
Open
baltierra wants to merge 1 commit into
Open
Conversation
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.
Adds two tables to support tracking which messages have been used to mint DOIs, enabling duplicate-DOI detection for consumers like Hermes without depending on Zenodo's API for that lookup.
archive/migrations/0006_add_doi_tracking.sqldois: one row per minted DOI (doi string, record URL, title, creator, timestamp). Unique index ondoi.doi_messages: many-to-many between DOIs and message UUIDs. Composite primary key (doi_id,message_uuid), cascade-delete FK todois, and an index onmessage_uuidfor fast reverse lookup ("which DOIs is this message part of?").No FK to
messages.uuid— that column only has a non-unique index, not a unique constraint, so a hard FK could break inserts in edge cases already handled elsewhere (duplicate message ingestion).archive/database_api.pysqlalchemy.Tabledeclarations for both new tables, following the existing pattern used formessages/topics.insert_doi(doi, record_url, title, created_by, message_uuids): inserts onedoisrow plus its associateddoi_messagesrows in a single transaction.find_dois_for_messages(message_uuids): given a candidate set of UUIDs, returns every message belonging to any DOI that overlaps at all with that set (not just the overlapping members). This lets callers distinguish an exact-duplicate package (same message set, same size) from a partial overlap (a message reused inside a different, larger package) using only counts — without needing a second round-trip query.archive/access_api.pyrecord_doi,find_dois_for_messages) added toArchive_access, matching the existing convention. No business logic here, consistent with every other method in this class.