-
Notifications
You must be signed in to change notification settings - Fork 2
refactor(db): remove redundant data, significantly simplify #629
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
Open
cooper (czxtm)
wants to merge
1
commit into
push-vrqxytmztspo
Choose a base branch
from
push-tkywkxswnmkq
base: push-vrqxytmztspo
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,79 +1,61 @@ | ||
| CREATE TABLE IF NOT EXISTS commits ( | ||
| id INTEGER PRIMARY KEY, | ||
| hash TEXT NOT NULL UNIQUE, | ||
| tree_hash TEXT NOT NULL, | ||
| message TEXT, | ||
| -- Content-addressed summary schema. | ||
| -- | ||
| -- Summaries describe *what a patch does*, keyed only by the content hash of the | ||
| -- change(s) they cover. Git remains the source of truth for diffs; these tables | ||
| -- are a local cache that can always be rebuilt by re-summarizing. | ||
|
|
||
| -- Per-change summary. Used for singletons / fallback (a change the model | ||
| -- described on its own, or a one-member group). | ||
| CREATE TABLE IF NOT EXISTS patch_summaries ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| change_hash TEXT NOT NULL UNIQUE, | ||
| title TEXT NOT NULL DEFAULT '', | ||
| description TEXT NOT NULL DEFAULT '', | ||
| status TEXT NOT NULL DEFAULT 'DONE' CHECK(status IN ('QUEUED', 'DONE', 'FAILED', 'CANCELLED')), | ||
| created_at INTEGER NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS evolutions ( | ||
| -- First-class group summary. `group_key` content-addresses the exact set of | ||
| -- member change hashes (sha256 of the sorted hashes), so a group's identity is | ||
| -- its membership. | ||
| CREATE TABLE IF NOT EXISTS summary_groups ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| origin_branch TEXT NOT NULL, | ||
| merged INTEGER NOT NULL DEFAULT 0, | ||
| builds INTEGER NOT NULL DEFAULT 0 | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS change_summaries ( | ||
| id INTEGER PRIMARY KEY, | ||
| group_key TEXT NOT NULL UNIQUE, | ||
| title TEXT NOT NULL DEFAULT '', | ||
| description TEXT NOT NULL DEFAULT '', | ||
| status TEXT NOT NULL DEFAULT 'QUEUED' CHECK(status IN ('QUEUED', 'DONE', 'FAILED', 'CANCELLED')), | ||
| status TEXT NOT NULL DEFAULT 'DONE' CHECK(status IN ('QUEUED', 'DONE', 'FAILED', 'CANCELLED')), | ||
| created_at INTEGER NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS changes ( | ||
| id INTEGER PRIMARY KEY, | ||
| hash TEXT NOT NULL UNIQUE, | ||
| filename TEXT NOT NULL, | ||
| diff TEXT NOT NULL, | ||
| line_count INTEGER NOT NULL, | ||
| created_at INTEGER NOT NULL, | ||
| own_summary_id INTEGER REFERENCES change_summaries(id) | ||
| -- Membership of a group. Content-addressed by `group_key`. | ||
| CREATE TABLE IF NOT EXISTS summary_group_members ( | ||
| group_key TEXT NOT NULL REFERENCES summary_groups(group_key), | ||
| change_hash TEXT NOT NULL, | ||
| PRIMARY KEY (group_key, change_hash) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS group_summaries ( | ||
| change_id INTEGER NOT NULL REFERENCES changes(id), | ||
| change_summary_id INTEGER NOT NULL REFERENCES change_summaries(id) | ||
| -- Thin evolution record — just the origin branch an evolution started from. | ||
| CREATE TABLE IF NOT EXISTS evolutions ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| origin_branch TEXT NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS change_sets ( | ||
| -- A snapshot caches the generated commit message for an exact set of change | ||
| -- hashes. `snapshot_key` = sha256(sorted change hashes). The integer `id` is the | ||
| -- value historically plumbed as `changeset_id` throughout evolve/build state. | ||
| CREATE TABLE IF NOT EXISTS snapshots ( | ||
| id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
| commit_id INTEGER REFERENCES commits(id), | ||
| base_commit_id INTEGER NOT NULL REFERENCES commits(id), | ||
| commit_message TEXT, | ||
| snapshot_key TEXT NOT NULL UNIQUE, | ||
| generated_commit_message TEXT, | ||
| created_at INTEGER NOT NULL, | ||
| evolution_id INTEGER REFERENCES evolutions(id) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS set_changes ( | ||
| change_set_id INTEGER NOT NULL REFERENCES change_sets(id), | ||
| change_id INTEGER NOT NULL REFERENCES changes(id), | ||
| PRIMARY KEY (change_set_id, change_id) | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS queued_summaries ( | ||
| id INTEGER PRIMARY KEY, | ||
| status TEXT NOT NULL DEFAULT 'QUEUED' CHECK(status IN ('QUEUED', 'DONE', 'FAILED', 'CANCELLED')), | ||
| attempted_count INTEGER NOT NULL DEFAULT 0, | ||
| prompt TEXT NOT NULL, | ||
| model_response TEXT, | ||
| group_summary_id INTEGER REFERENCES change_summaries(id), | ||
| hash_own_summary_id_pairs TEXT, | ||
| type TEXT NOT NULL CHECK(type IN ('NEW_SINGLE', 'NEW_GROUP', 'EVOLVED_GROUP')) | ||
| evolution_id INTEGER REFERENCES evolutions(id), | ||
| created_at INTEGER NOT NULL | ||
| ); | ||
|
|
||
| CREATE TABLE IF NOT EXISTS prompts ( | ||
| id INTEGER PRIMARY KEY, | ||
| text TEXT NOT NULL, | ||
| commit_id INTEGER REFERENCES commits(id) ON DELETE SET NULL, | ||
| created_at INTEGER NOT NULL | ||
| -- Records which commits were created by a restore operation and their origin. | ||
| CREATE TABLE IF NOT EXISTS restore_commits ( | ||
| commit_hash TEXT PRIMARY KEY, | ||
| origin_hash TEXT NOT NULL | ||
| ); | ||
|
|
||
| CREATE INDEX IF NOT EXISTS idx_commits_tree_hash ON commits(tree_hash); | ||
| CREATE INDEX IF NOT EXISTS idx_evolutions_origin_branch ON evolutions(origin_branch); | ||
| CREATE INDEX IF NOT EXISTS idx_prompts_commit ON prompts(commit_id); | ||
| CREATE INDEX IF NOT EXISTS idx_change_sets_commit ON change_sets(commit_id); | ||
| CREATE INDEX IF NOT EXISTS idx_change_sets_base ON change_sets(base_commit_id); | ||
| CREATE INDEX IF NOT EXISTS idx_set_changes_change ON set_changes(change_id); | ||
| CREATE INDEX IF NOT EXISTS idx_queued_summaries_status ON queued_summaries(status); | ||
| CREATE INDEX IF NOT EXISTS idx_summary_group_members_hash ON summary_group_members(change_hash); | ||
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
apps/native/src-tauri/migrations/03-drop-queued-summaries/up.sql
This file was deleted.
Oops, something went wrong.
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
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.
Caution
The entire
01-initialmigration is rewritten in place, and migrations02-restore-commitsand03-drop-queued-summariesare deleted — but no new migration (e.g.04-new-schema) is added to carry existing databases forward. Diesel migrations are identified by directory name and tracked in__diesel_schema_migrations; any database that already applied01-initialwill not re-run it, sopatch_summaries,summary_groups,summary_group_members, andsnapshotsare never created, causing every call todb::summariesanddb::snapshotsto fail with "no such table." The state management migration plan locks "Preserve compatibility during frontend migration" and requires migrations to be "tested against temporary database," with no provision for rewriting baseline migrations in place.