-
Notifications
You must be signed in to change notification settings - Fork 649
database: Change num_no_build
to be NOT NULL
#9767
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #9767 +/- ##
=======================================
Coverage 88.81% 88.81%
=======================================
Files 289 289
Lines 29810 29820 +10
=======================================
+ Hits 26475 26485 +10
Misses 3335 3335 ☔ View full report in Codecov by Sentry. |
#[builder(default = strip_build_metadata(num))] | ||
num_no_build: &'a str, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
argh, I screwed this up... this part of the diff should've been in the previous PR instead. every new version is currently inserted with num_no_build = NULL
, which makes the set not null
migration in this PR fail 🤦♂️
update versions
set num_no_build = split_part(num, '+', 1)
where num_no_build IS NULL;
I will run ⬆️ right before deploying, which should be enough for this to deploy cleanly...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, that worked. all good now! :)
When I tried to import data using
I believe this error occurred because the |
Another idea would be to modify the script template, changing the DDL to allow |
that basic version of the backfill won't help for the full dataset though, because it would cause uniqueness issues on the corresponding index for some of the older versions where we still allowed for duplicates :-/ |
If we have an UPDATE command that can do a 100% faithful backfill cheaply, is there a place we can put that? Somewhere in import.sql? If not, let's revert #9786. This worked for me on today's db-dump: CREATE TABLE public.versions ( ..., num_no_build VARCHAR, ... );
\copy versions (bin_names, checksum, crate_id, crate_size, created_at, downloads, edition, features, has_lib, id, license, links, num, published_by, rust_version, updated_at, yanked) FROM 'versions.csv' WITH CSV HEADER
UPDATE versions
SET num_no_build = CASE WHEN deduplicate.count = 1 THEN deduplicate.nnb ELSE versions.num END
FROM
(SELECT crate_id, split_part(num, '+', 1) nnb, count(*)
FROM versions
GROUP BY crate_id, nnb) deduplicate
WHERE versions.crate_id = deduplicate.crate_id
AND split_part(versions.num, '+', 1) = deduplicate.nnb;
ALTER TABLE versions ALTER COLUMN num_no_build SET NOT NULL;
-- example crate with duplicates:
SELECT crate_id, num, num_no_build
FROM versions
WHERE crate_id = 1643
ORDER BY num; |
hmm, let me see if I can adjust our scripts to do this |
This PR was extracted from #9756, because it needs to be deploy separately from the other migrations in that PR.
The backfill SQL script in #9766 has been run on the staging and production databases, so this should be good to go.
SELECT * FROM versions WHERE num_no_build IS NULL
returns zero rows.