Repository navigation
Opt-in record version history (recordHistory query) #135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| kind: added | ||
| body: Add opt-in record version history. Collections listed in RECORD_HISTORY_COLLECTIONS (exact NSIDs or prefix.* patterns, Tap mode) keep every observed version and delete in a new record_version table, seeded on startup with a baseline row per existing record, and the new root recordHistory(uri, first) GraphQL query returns them oldest first. History is off by default; migration 015 adds the table. | ||
| time: 2026-09-23T03:10:00.000000+02:00 | ||
| custom: | ||
| Affects: operator |
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
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
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
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
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
1 change: 1 addition & 0 deletions
1
internal/database/migrations/postgres/015_add_record_version.down.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| DROP TABLE IF EXISTS record_version; |
22 changes: 22 additions & 0 deletions
22
internal/database/migrations/postgres/015_add_record_version.up.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| -- Append-only version history for opted-in collections | ||
| -- (RECORD_HISTORY_COLLECTIONS). One row per distinct record version (CID) the | ||
| -- indexer observes, plus delete tombstones. `baseline` rows seed the version | ||
| -- that was current when history was switched on for a collection. | ||
| CREATE TABLE IF NOT EXISTS record_version ( | ||
| id BIGSERIAL PRIMARY KEY, | ||
| uri TEXT NOT NULL, | ||
| cid TEXT NOT NULL, | ||
| did TEXT NOT NULL, | ||
| collection TEXT NOT NULL, | ||
| action TEXT NOT NULL CHECK (action IN ('baseline', 'create', 'update', 'delete')), | ||
| json JSONB, | ||
| live BOOLEAN, | ||
| observed_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW() | ||
| ); | ||
|
|
||
| -- A version is recorded once, however often Tap redelivers or resyncs it. | ||
| CREATE UNIQUE INDEX IF NOT EXISTS idx_record_version_uri_cid | ||
| ON record_version(uri, cid) WHERE action <> 'delete'; | ||
| CREATE INDEX IF NOT EXISTS idx_record_version_uri_id ON record_version(uri, id); | ||
| CREATE INDEX IF NOT EXISTS idx_record_version_collection_observed | ||
| ON record_version(collection, observed_at DESC); |
1 change: 1 addition & 0 deletions
1
internal/database/migrations/sqlite/015_add_record_version.down.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| DROP TABLE IF EXISTS record_version; |
19 changes: 19 additions & 0 deletions
19
internal/database/migrations/sqlite/015_add_record_version.up.sql
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| -- Append-only version history for opted-in collections | ||
| -- (RECORD_HISTORY_COLLECTIONS). See the PostgreSQL migration for details. | ||
| CREATE TABLE IF NOT EXISTS record_version ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| uri TEXT NOT NULL, | ||
| cid TEXT NOT NULL, | ||
| did TEXT NOT NULL, | ||
| collection TEXT NOT NULL, | ||
| action TEXT NOT NULL CHECK (action IN ('baseline', 'create', 'update', 'delete')), | ||
| json TEXT, | ||
| live INTEGER, | ||
| observed_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now')) | ||
| ); | ||
|
|
||
| CREATE UNIQUE INDEX IF NOT EXISTS idx_record_version_uri_cid | ||
| ON record_version(uri, cid) WHERE action <> 'delete'; | ||
| CREATE INDEX IF NOT EXISTS idx_record_version_uri_id ON record_version(uri, id); | ||
| CREATE INDEX IF NOT EXISTS idx_record_version_collection_observed | ||
| ON record_version(collection, observed_at DESC); |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.