Skip to content

Remove duplicate crates.version column #544

Closed
@jyn514

Description

@jyn514
Member

Reported by @koenaad:

So, I was checking out the database of docs.rs, I am a bit confused about why there is a column versions in the crates table: https://github.com/rust-lang/docs.rs/blob/master/src/db/migrate.rs#L105
The table releases contains the releases per crate and also has a column version. So the same information can be retrieved by doing a join between crates and releases. Something like this:

select crates."name", releases."version", releases.release_time, releases.build_status
from releases
inner join crates on releases.crate_id = crates.id
where crates.name = 'fie'
order by releases.release_time desc;

It seems to kept in sync by add_package: https://github.com/rust-lang/docs.rs/blob/master/src/db/add_package.rs#L151.

There's no sense in storing duplicate data in postgres, so I'd like to see the crates.version column removed eventually.

Activity

yvrhdn

yvrhdn commented on Jan 4, 2020

@yvrhdn

I can remove the use of crates.versions in crate_details.rs (https://github.com/rust-lang/docs.rs/blob/master/src/web/crate_details.rs#L114) when implementing the 2nd change of #516 (comment)

jyn514

jyn514 commented on Jan 4, 2020

@jyn514
MemberAuthor

I would rather separate feature PRs from refactoring PRs. Our test suite still isn't as good as I'd like and smaller PRs makes it easier to rollback commits. This is especially true for the SQL queries which are mostly not type checked, if you delete crates.version there will be no compile errors but the site may panic at runtime.

self-assigned this
on Jan 4, 2020
jyn514

jyn514 commented on Jan 4, 2020

@jyn514
MemberAuthor

See #466 for an example of a PR that passed all tests but still crashed the site.

(This is why this issue is marked as wishlist)

jyn514

jyn514 commented on Jun 27, 2020

@jyn514
MemberAuthor

Fixed in #804

added
P-lowLow priority issues
and removed on Jun 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P-lowLow priority issues

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @yvrhdn@jyn514

      Issue actions

        Remove duplicate `crates.version` column · Issue #544 · rust-lang/docs.rs