Restore DAV database invariants and sync indexes#276
Open
AnnoyingTechnology wants to merge 1 commit into
Open
Conversation
AnnoyingTechnology
force-pushed
the
database-invariants
branch
2 times, most recently
from
July 20, 2026 17:42
182af78 to
937639f
Compare
Add the collection-scoped uniqueness constraints expected by the SabreDAV PDO backends, including the path/name constraint required by property upserts. Add compound indexes matching calendar and address-book sync queries.\n\nAbort with an actionable message when legacy duplicates would make a unique index unsafe rather than deleting or merging user data.
AnnoyingTechnology
force-pushed
the
database-invariants
branch
from
July 20, 2026 17:43
937639f to
178049a
Compare
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.
Why
The schema omits database invariants assumed by the SabreDAV PDO backends. SQLite is affected most sharply: its migration-created tables have no foreign keys at all, and SQLite does not enforce declared foreign keys unless every connection enables them.
This is also correctness-sensitive in
propertystorage: PostgreSQL usesON CONFLICT (path, name), which requires a matching unique key, while SQLite and MariaDB useREPLACE, which only replaces the existing property when that key is unique. DAV resource identifiers are likewise collection-scoped in the application but not consistently constrained in the database. Finally, incremental sync filters and orders change rows by collection and token while the schema indexes only the collection.SQLite should be a first-class database here. The same integrity semantics must remain true on MariaDB and PostgreSQL; this PR does not remove or reduce support for either.
What changed
(calendarid, synctoken)and(addressbookid, synctoken)indexes for incremental syncVerification