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

Add extra DB constraints #97

Closed
mizdebsk opened this issue May 18, 2016 · 4 comments
Closed

Add extra DB constraints #97

mizdebsk opened this issue May 18, 2016 · 4 comments
Assignees

Comments

@mizdebsk
Copy link
Member

mizdebsk commented May 18, 2016

For better DB consistency we should add additional constraints.

KojiTask

state BETWEEN 0 AND 5
started IS NOT NULL
-- Not running tasks must have finished timestamp set
state = 0 OR state = 1 OR state = 4 OR finished IS NOT NULL
arch IS NOT NULL

Build

state BETWEEN 2 AND 5
task_id IS NOT NULL
started IS NOT NULL
-- Not running builds must have finished timestamp set
state <> 2 OR finished IS NOT NULL
-- Complete builds must have version set
state <> 3 OR version IS NOT NULL
-- Complete builds must have release set
state <> 3 OR release IS NOT NULL
-- Complete builds must have repo_id set
state <> 3 OR repo_id IS NOT NULL
-- Only running builds can have cancelation request
state = 2 OR NOT cancel_requested
-- Only builds with deps processed can have deps resolved
NOT deps_resolved OR deps_processed
-- Real builds must be complete
NOT real OR state = 3
@mizdebsk
Copy link
Member Author

I ran these constrains against production database. Three of them are violated (all for Build table):

  • started IS NOT NULL (2 builds violate this; both are real, complete builds)
  • state <> 2 OR finished IS NOT NULL (not running builds must have finished timestamp set; 37 builds violate this)
  • state <> 3 OR repo_id IS NOT NULL (complete builds must have repo_id set; violated by 907 builds)

@mizdebsk mizdebsk assigned mizdebsk and msimacek and unassigned mizdebsk May 18, 2016
msimacek added a commit that referenced this issue May 18, 2016
@msimacek
Copy link
Contributor

There's one more constraint I'd like to have - groups are currently joined with package on name, but it's missing foreign key constraint. It should be added.

@msimacek
Copy link
Contributor

msimacek commented Jul 1, 2016

Almost everything has been added already, except:

  • KojiTask timestamps - we weren't sure whether we can rely on them and they aren't used by anything, not even displayed
  • cancel_request - cancelling koji builds is indempotent operation, I really think it's not worth compilcating both frontend and backend with locking for this

@mizdebsk
Copy link
Member Author

mizdebsk commented Apr 5, 2017

I believe that there is nothing more left to do here. Closing.

@mizdebsk mizdebsk closed this as completed Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants