Skip to content

chore: Refactor common db capabilities into separate crate#1685

Merged
sergerad merged 20 commits intonextfrom
sergerad-db-crate
Feb 19, 2026
Merged

chore: Refactor common db capabilities into separate crate#1685
sergerad merged 20 commits intonextfrom
sergerad-db-crate

Conversation

@sergerad
Copy link
Collaborator

@sergerad sergerad commented Feb 18, 2026

Context

We have started using the sqlite capabilities found in the store crate in other crates (validator and ntx-builder).

The validator crate currently depends on db-related store code. This is a dependancy that we do not want to maintain.

The ntx-builder crate currently duplicates some db-related code that we can consolidate.

Note that the apply_migration() fns cannot be consolidated because of the const nature of the relevant API.

Closes #1653.

Changes

  • Move common db functionality from store crate into new db crate.
  • Update validator crate to no longer depend on store crate.
  • Remove duplicate db-related code from validator and ntx-builder.
  • Remove unnecessary error enums and variants from the store.

@sergerad sergerad added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Feb 18, 2026
@sergerad sergerad marked this pull request as ready for review February 18, 2026 07:08
Comment on lines +6 to +15
//! Notice: All of them are infallible. The invariant is a sane content of the database
//! and humans ensure the sanity of casts.
//!
//! Notice: Keep in mind if you _need_ to expand the datatype, only if you require sorting this is
//! mandatory!
//!
//! Notice: Ensure you understand what casting does at the bit-level before changing any.
//!
//! Notice: Changing any of these are _backwards-incompatible_ changes that are not caught/covered
//! by migrations!
Copy link
Contributor

Choose a reason for hiding this comment

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

I really struggled formulating these..

diesel::sql_query("PRAGMA foreign_keys=ON")
.execute(conn)
.map_err(ConnectionManagerError::ConnectionParamSetup)?;
Ok(())
Copy link
Contributor

Choose a reason for hiding this comment

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

These pragmas got lost while we added the timeout for all of them. I don't think that's right.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry I'm not following - those pragmas are all still in configure_connection_on_creation() crates/db/src/manager.rs? Or is that not what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I see, this is just ntx, and it's intentional you drop these?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yea ntx builder should use the same consolidated fns as store and validator

Copy link
Contributor

@drahnr drahnr left a comment

Choose a reason for hiding this comment

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

I don't think the query params as used are unified properly/should be unified but depends on context which one is needed.

Otherwise LGTM

Copy link
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

I'm still on the fence about doing this before having a concrete plan in mind to evolve this. But lets see how it goes.

@sergerad
Copy link
Collaborator Author

I'm still on the fence about doing this before having a concrete plan in mind to evolve this. But lets see how it goes.

Interested to see how ntx-builder goes with the db crate. At that point we will have 3 concrete use cases to design around.

@sergerad sergerad merged commit be2771d into next Feb 19, 2026
19 checks passed
@sergerad sergerad deleted the sergerad-db-crate branch February 19, 2026 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add DB crate that store and validator use

3 participants