-
Notifications
You must be signed in to change notification settings - Fork 18.8k
feat(core): initial implementation of syncing #17814
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 all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ec9ad4b
feat(core): initial implementation of syncing
jlongster 5f1db94
Update types
jlongster b76df3b
Refactor API
jlongster a9a35dc
Put event table write behind flag
jlongster f9c2ab0
Fix SDK conflicts
jlongster accb342
Fix db conflicts
jlongster 1c7cf2b
wip
jlongster 407746c
Change how we integrate with Bus
jlongster 34d7423
Restore SDK
jlongster e717b32
Regenerate SDK
jlongster 36e2a28
Cleanup
jlongster deae32b
cleanup
jlongster a9a6b45
Remove isTesting addition
jlongster 3e993e6
Bug fixes
jlongster bd705f6
Fix tests
jlongster 7d50ca0
db field tweaks
jlongster 89d1ccc
Fix tests
jlongster bff2c45
Fix tests
jlongster a2382e2
cleanup
jlongster 48e5476
Remove test files
jlongster 3d34872
Write more notes
jlongster 4d43226
Add back fix for circular dep to fix tests
jlongster 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
13 changes: 13 additions & 0 deletions
13
packages/opencode/migration/20260323234822_events/migration.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,13 @@ | ||
| CREATE TABLE `event_sequence` ( | ||
| `aggregate_id` text PRIMARY KEY, | ||
| `seq` integer NOT NULL | ||
| ); | ||
| --> statement-breakpoint | ||
| CREATE TABLE `event` ( | ||
| `id` text PRIMARY KEY, | ||
| `aggregate_id` text NOT NULL, | ||
| `seq` integer NOT NULL, | ||
| `type` text NOT NULL, | ||
| `data` text NOT NULL, | ||
| CONSTRAINT `fk_event_aggregate_id_event_sequence_aggregate_id_fk` FOREIGN KEY (`aggregate_id`) REFERENCES `event_sequence`(`aggregate_id`) ON DELETE CASCADE | ||
| ); | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want an index on
event(aggregate_id, seq)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I almost did that! well, not an explicit index, but a constraint saying that the combo of
(aggregate_id, seq)was always unique to ensure we don't insert duplicate events (or make sure sequences aren't messed up).An index can make writes slower, and consumes more memory, so I decided to wait until we understand the tradeoffs here better. We will be querying the latest events for an aggregate quite a bit so an index probably makes sense, but want to measure it first