Skip to content
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

feat(db): add database version management system #431

Merged
merged 1 commit into from
Jan 3, 2025
Merged

Conversation

jbcaron
Copy link
Member

@jbcaron jbcaron commented Dec 18, 2024

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Feature
  • Build-related changes

What is the current behavior?

Currently there is no system to manage database version compatibility between binary releases. This can lead to data corruption or unexpected behavior when users upgrade their binary without migrating their database.

Resolves: #NA

What is the new behavior?

  • Adds a robust database version management system
  • Implements version checks at database startup
  • Provides tooling for automatic version bumping in CI

Key components added:

  • .db-versions.yml file to track version history with PR references
  • Build-time version validation via build.rs
  • GitHub workflow for automatic version bumping
  • Version compatibility check at runtime
  • CLI script for version management
  • Comprehensive error handling and validation

Files added/modified:

  • .db-versions.yml - Version tracking file
  • scripts/update-db-version.sh - Version bump script
  • .github/workflows/pull_request.yml - CI integration
  • .github/workflows/db-version.yml - CI integration
  • crates/client/db/build.rs - Build-time version extraction
  • crates/client/db/src/db_version.rs Runtime version validation code
  • .github/labels.yml - Added 'bump_db' label

Does this introduce a breaking change?

No, this is a new feature that adds safety checks without modifying existing behavior. However, after this PR:

  • PRs modifying database schema must include the 'bump_db' label
  • Binary will refuse to start if database version is incompatible

Other information

To use the new version system:

  1. Add 'bump_db' label to PRs that modify database schema
  2. CI will automatically increment version and update history
  3. Build system will embed current version in binary
  4. Runtime checks will ensure version compatibility

@jbcaron jbcaron requested a review from cchudant December 18, 2024 13:58
@jbcaron jbcaron self-assigned this Dec 18, 2024
@jbcaron jbcaron changed the title feat: db-version feat(db): add database version management system Dec 18, 2024
Copy link
Member

@antiyro antiyro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm would be great to add documentation for contributors on how to trigger bump_db

.github/workflows/db-version.yml Show resolved Hide resolved
@jbcaron jbcaron force-pushed the build/db-version branch 2 times, most recently from 2945ec5 to 4bd1826 Compare December 18, 2024 18:14
@jbcaron jbcaron requested a review from apoorvsadana December 18, 2024 18:16
Copy link
Member

@cchudant cchudant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very cool!

@Trantorian1 Trantorian1 added feature Request for new feature or enhancement research Research and exploration required before implementation labels Dec 31, 2024
@jbcaron jbcaron force-pushed the build/db-version branch 5 times, most recently from 391b694 to 97ea3f1 Compare January 3, 2025 16:40
Copy link
Collaborator

@Trantorian1 Trantorian1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good!

Comment on lines +11 to +16
//! current_version: 42
//! versions:
//! - version: 42
//! pr: 123
//! - version: 41
//! pr: 120
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//! current_version: 42
//! versions:
//! - version: 42
//! pr: 123
//! - version: 41
//! pr: 120
//! current_version: 69
//! versions:
//! - version: 69
//! pr: 420
//! - version: 68
//! pr: 419

@jbcaron jbcaron removed the research Research and exploration required before implementation label Jan 3, 2025
@jbcaron jbcaron merged commit 922d7a8 into main Jan 3, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request for new feature or enhancement
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants