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

could db schema and model enforce that IP/port are present iff kind = 'crucible'? #7301

Open
davepacheco opened this issue Jan 2, 2025 · 1 comment

Comments

@davepacheco
Copy link
Collaborator

I can't find a primary source for this but I believe that for datasets, the IP and port fields are supposed be populated if and only if the dataset kind is "crucible". This comment suggests it:

omicron/schema/crdb/dbinit.sql

Lines 3769 to 3771 in c140817

-- Only valid if kind = crucible
ip INET,
port INT4 CHECK (port BETWEEN 0 AND 65535),

Both this table and the "dataset" table have an explicit constraint to enforce one side of this:

CONSTRAINT ip_and_port_set_for_crucible CHECK (
(kind != 'crucible') OR
(kind = 'crucible' AND ip IS NOT NULL and port IS NOT NULL)
),

but they allows rows of kind != crucible that have an IP and port set.

If these are unexpected, could we enforce both sides of this in both tables? And also in the model types? I'm hopeful that catch problems like #7299.

@davepacheco
Copy link
Collaborator Author

Given #7299, if we were to enforce this in a new schema, we'd also need to fix up existing rows in these tables, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant