Skip to content

Add dois/doi_messages tables and data-access methods - #12

Open
baltierra wants to merge 1 commit into
masterfrom
feature/doi-tracking-tables
Open

Add dois/doi_messages tables and data-access methods#12
baltierra wants to merge 1 commit into
masterfrom
feature/doi-tracking-tables

Conversation

@baltierra

Copy link
Copy Markdown

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.sql

  • dois: one row per minted DOI (doi string, record URL, title, creator, timestamp). Unique index on doi.
  • doi_messages: many-to-many between DOIs and message UUIDs. Composite primary key (doi_id, message_uuid), cascade-delete FK to dois, and an index on message_uuid for 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.py

  • sqlalchemy.Table declarations for both new tables, following the existing pattern used for messages/topics.
  • insert_doi(doi, record_url, title, created_by, message_uuids): inserts one dois row plus its associated doi_messages rows 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.py

  • Thin pass-through wrapper methods (record_doi, find_dois_for_messages) added to Archive_access, matching the existing convention. No business logic here, consistent with every other method in this class.

@baltierra
baltierra requested a review from cnweaver August 26, 2026 16:42
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.

1 participant