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

Fix for legacy location_id=0 issue that can cause failure to checkout/checkin #8605

Merged
merged 3 commits into from
Oct 23, 2020

Conversation

snipe
Copy link
Owner

@snipe snipe commented Oct 23, 2020

This is a smallish PR that tries to correct the issue of folks not being able to checkin/checkout because they have 0 as a value for either location_id or rtd_location_id.

In previous versions of Snipe-IT, we weren't as strict about validating location selections, so it would allow you to save an asset or a user with an invalid location_id. This doesn't exactly fix that, but rather just tries to correct a zero value for location_id, since that would never be valid in our system. It doesn't try to check whether the location is actually valid (as in, there is a record for it in the database that's not been deleted/purged), but it at least tries to correct the 0 issue for legacy systems.

It includes a migration to do a one-time sweep of the assets and users tables, and also adds a little bit of logic to override that at the checkout/checkin layer, and pass at least slightly more helpful error messages. (Before you would just get "Asset was not checked in", which doesn't really help anyone figure out what's happening.)

The migration is basically the equivalent of running:

UPDATE assets SET rtd_location_id = NULL WHERE rtd_location_id='0'; 
UPDATE assets SET location_id = NULL WHERE location_id='0';
UPDATE users SET location_id = NULL WHERE location_id='0';

@snipe snipe requested a review from uberbrady October 23, 2020 21:15
Copy link
Collaborator

@uberbrady uberbrady left a comment

Choose a reason for hiding this comment

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

This looks good and makes sense to me, I approve. One minor inconsistency - but not enough so to hold up the PR.

@snipe snipe merged commit 6ee3d0e into develop Oct 23, 2020
@snipe snipe deleted the fixes/legacy_location_id_equals_zero branch October 23, 2020 21:22
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