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

Create a BackendStatus -> numeric mapping #755

Merged
merged 2 commits into from
Jun 25, 2024

Conversation

paulgb
Copy link
Member

@paulgb paulgb commented Jun 25, 2024

The backend status lifecycle has a strict ordering. Backends can move forward in the lifecycle, but not backwards.

On the Rust side, BackendStatus is PartialOrd, so we can do natural comparisons between backend statuses as they relate to this order. However, on the database side, they are just strings.

We would like to add constraints at the database level, such as "a backend status can never go backwards". In the database, statuses are represented as strings. We could re-implement the comparison logic in the database as a function over strings, but I don't love having the logic live in both Rust and the database.

The alternative implemented here is to create a function from BackendStatus -> i32 which produces a number that reflects the natural order of statuses.

No Plane behavior is changed in this PR. The next step is to do a migration that stores these numbers alongside the status.

@paulgb paulgb requested a review from rolyatmax June 25, 2024 16:48
Copy link

vercel bot commented Jun 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
plane ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2024 4:48pm

Copy link
Member

@rolyatmax rolyatmax left a comment

Choose a reason for hiding this comment

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

LGTM!

@paulgb paulgb merged commit e9a3f01 into main Jun 25, 2024
6 checks passed
@paulgb paulgb deleted the paul/dis-2210-create-a-backendstatus-numeric-mapping branch June 25, 2024 17:04
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

Successfully merging this pull request may close these issues.

2 participants