[dbinit.sql] Make some columns NOT NULL#9976
Merged
Merged
Conversation
smklein
commented
Mar 5, 2026
jgallagher
reviewed
Mar 5, 2026
This was referenced Mar 5, 2026
Collaborator
Author
|
I think I've addressed all comments here - thanks everyone for the feedback. Anyone willing to give this a look / approval? Or are there any outstanding concerns? |
Collaborator
Author
|
Unless anyone has further objections, I'll plan on landing this about 24 hours from now. Happy to pause for additional feedback, but otherwise I'd like to keep the ball rolling on aligning diesel's schema with Cockroach's. |
jgallagher
added a commit
that referenced
this pull request
May 4, 2026
…e strict (#10155) Staged on top of #10122, which strengthened the types used for BGP peers in the external API. * Always represent unnumbered peers as a `NULL` address * Add `CHECK` constraints that prevent storing the addresses `0.0.0.0` or `::` to ensure we don't have any leftover sentinel values * For the three tables that required the address to be non-NULL because it was part of a composite primary key, add a new synthetic `id` primary key (a random UUID) The database migrations are similar in spirit to #9976: while we're not correcting mismatches between diesel and CRDB here, we are introducing migrations that _could_ fail if real databases have data we don't expect (e.g., an address of `0.0.0.0` in the table where we expect unnumbered peers to be represented as NULL). The tactic I went with in the migration is: * If there's only one unnumbered peer (treating NULL, 0.0.0.0, :: all as possibilities), convert it to `NULL`. * If there are multiple, keep one (preferring `NULL` then `0.0.0.0`) and delete the rest. This shouldn't delete anything unless someone has some already-invalid-at-runtime data. There's a data migration test that should cover a sample of each kind of possibly-invalid input and confirm the above behavior. One other thing that snuck in here is a bugfix for #10151.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This schema change aligns the database with existing diesel models in Rust
Part of #9966