Skip to content

database/versions: Add generated version_no_prerelease column #3992

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE versions
DROP COLUMN version_no_prerelease;
3 changes: 3 additions & 0 deletions migrations/2021-10-07-220812_add_version_no_prerelease/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE versions
ADD COLUMN version_no_prerelease semver_triple
GENERATED ALWAYS AS ( to_semver_no_prerelease(num) ) STORED;
2 changes: 1 addition & 1 deletion src/models/krate_reverse_dependencies.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SELECT *, COUNT(*) OVER () as total FROM (
SELECT versions.*,
row_number() OVER (
PARTITION BY crate_id
ORDER BY to_semver_no_prerelease(num) DESC NULLS LAST
ORDER BY version_no_prerelease DESC NULLS LAST
) rn
FROM versions
WHERE NOT yanked
Expand Down
1 change: 1 addition & 0 deletions src/tasks/dump_db/dump-db.toml
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ yanked = "public"
license = "public"
crate_size = "public"
published_by = "public"
version_no_prerelease = "private"

[versions_published_by.columns]
version_id = "private"
Expand Down