VB-Toml to DB migration: sync toml to DB as first step#12263
VB-Toml to DB migration: sync toml to DB as first step#12263Byron merged 4 commits intogitbutlerapp:masterfrom
Conversation
|
@Byron is attempting to deploy a commit to the GitButler Team on Vercel. A member of the Team first needs to authorize it. |
e50df01 to
784c8f5
Compare
|
Deployment failed with the following error: |
78829a6 to
51b4043
Compare
81721a1 to
25ab444
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements the first step of migrating from TOML-based virtual branches metadata to a database-backed approach. The core change synchronizes .git/gitbutler/virtual-branches.toml with an equivalent SQLite database representation while maintaining backward compatibility by continuing to write the TOML file.
Changes:
- Added normalized database schema for virtual branches metadata (vb_state, vb_stacks, vb_stack_heads, vb_branch_targets tables)
- Implemented bidirectional TOML↔DB synchronization with mtime+SHA256 conflict detection
- Updated VirtualBranchesHandle to transparently use DB with TOML mirroring for backward compatibility
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| etc/plans/consistent-data.md | Comprehensive plan document outlining data consistency migration strategy |
| crates/but-db/src/table/virtual_branches.rs | New normalized database schema with savepoint-based mutation API |
| crates/but-db/src/table/mod.rs | Registered virtual_branches module |
| crates/but-db/src/lib.rs | Exported VirtualBranches types and added migration, enforced documentation |
| crates/but-db/src/migration.rs | Enabled foreign key enforcement in improve_concurrency |
| crates/but-db/src/poll.rs | Added documentation to poll types |
| crates/but-db/tests/db/table/virtual_branches.rs | Comprehensive tests for VB snapshot operations and FK cascades |
| crates/but-db/tests/db/table/mod.rs | Added virtual_branches test module |
| crates/but-db/tests/db/migration.rs | Updated expected schema to include VB tables |
| crates/but-db/tests/db/transaction.rs | Added savepoint isolation test demonstrating consistent multi-table reads |
| crates/but-meta/src/legacy/storage.rs | Core TOML↔DB synchronization logic with conflict resolution |
| crates/but-meta/src/legacy/mod.rs | Refactored to use storage module for read/write operations |
| crates/but-meta/src/lib.rs | Exported legacy_storage module |
| crates/but-meta/Cargo.toml | Added but-db, but-fs, and sha2 dependencies |
| crates/but-meta/tests/meta/ref_metadata_legacy.rs | Updated tests to reflect TOML mirror behavior (no longer deleted) |
| crates/gitbutler-stack/src/state.rs | Updated VirtualBranchesHandle to use synchronized storage |
| crates/gitbutler-stack/Cargo.toml | Removed but-fs dependency (moved to but-meta) |
| crates/gitbutler-stack/tests/mod.rs | Extensive sync behavior tests (bootstrap, recreation, newer TOML, invalid TOML, restore) |
| crates/gitbutler-oplog/src/oplog.rs | Added import_toml_into_db_for_restore call for oplog snapshot restoration |
| crates/but-db/src/table/*.rs | Added #![allow(missing_docs)] to existing table modules for consistency |
| Cargo.lock | Updated dependencies |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25ab4440e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The idea is that we are encouraged to write docs, without being forced if it's "too obvious" what's happening.
…l` file. It also keeps track of enough state to know if the snapshot is uptodate with the vb.toml file so it can be resynced at will. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
It will be used to track tasks relates to the transition towards data-consistency, probably maintained by an agent. Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
The source of truth is the database at least for `but-meta`, but it makes sure that the toml file stays in sync with the database and vice-versa. Adapt `but-oplog` and `VirtualBranchesHandle` to deal with database mirror correctly. Removed `toml_file_is_dirty` flag as it didn't seem useful. Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 40147d6a24
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Sync the vb.toml file to its equivalent database representation.
Goals
Tasks
VirtualBranchesHandle uses DB- no, it keeps using vb.toml file andbut-metais expected to auto-sync it anyway. Then the next step is to removeVirtualBranchesHandleusage from the codebase.Follow-ups
VirtualBranchesHandleusagesdb.meta()possible, and write the database after each change. Sync the toml file on drop only, knowing well that this may write data that is going to be rolled back, and only for backward compatbilityPrompts