oxidecomputer / oxidecomputer/omicron

use CockroachDB enums in more places in database schema

Open
#312 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

database
Dominant language
Rust
Stars
572
Forks
97
Avg merge
2d 12h
Merged PRs (30d)
96

Description

There are a few places in the schema where we'd like to use CockroachDB enums, but we were prevented by cockroachdb/cockroach#57411 / cockroachdb/cockroach#58084. This was supposed to be resolved in v21.1. So with #195 in, we should be able to switch to the enums. (This is worth confirming before doing too much work here.)

Examples where we want to use this:

  • "Instance" table, "state" field.
  • "Disk" table, "disk_state" field.
  • "Saga" table, "saga_state" field.
  • "SagaNodeEvent" table, "event_type" field.

I skimmed the schema to look for other candidates and I think that about covers it.

I expect this change will involve, for each of the above cases:

  • update the schema SQL to create the enum (many of these have a commented-out version already -- that needs to be compared to the actual Rust enum to make sure these are in sync)
  • presumably there's some change we need to make to the Diesel table! macro invocations, but I'm not sure what that looks like yet

I think that's it, but I'm not sure if there's something else we need to do on the Diesel side.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

First confirm that the CockroachDB v21.1 limitations in cockroachdb/cockroach#57411 and #58084 are resolved, then inspect the schema SQL, the commented enum definitions, the corresponding Rust enums, and the Diesel table! macro invocations. Done means the Instance.state, Disk.disk_state, Saga.saga_state, and SagaNodeEvent.event_type fields use synchronized enums throughout.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
databases
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.