Skip to content

feature: add document constraints for root and parent docs - #66

Merged
lebalz merged 11 commits into
mainfrom
feature/unique-documents
Oct 11, 2026
Merged

lebalz merged 11 commits into
mainfrom
feature/unique-documents

Conversation

@lebalz

@lebalz lebalz commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Adds optional, client-defined uniqueness constraints to Document to prevent duplicate models:

  • uniqOnRoot: unique per document root, author, type and key.
  • uniqOnParent: unique per document root, author, type, parent and key.

This supports one main document per user and root, or one child per key, such as a quiz qid. Both constraints are enforced by the database; documents without keys remain unrestricted.

Creating a document with an existing key returns the existing document (200); new documents return 201. Constraints can also be updated or cleared.

Includes migration support and cleanup of legacy duplicate main documents.

Some manual migration is needed for documents where the constraints could not be derived - check out the CHANGELOG.md for how to migrate.

Ensure to apply this changes only in combination with the frontend-changes GBSL-Informatik/teaching-dev#328.

signal-2026-10-07-155114

@lebalz
lebalz merged commit 8beff4d into main Oct 11, 2026
2 checks passed
@lebalz
lebalz deleted the feature/unique-documents branch October 11, 2026 15:15
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