Skip to content

[WIP] Remove latest_version_id in favor of a database index #892

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 1 commit 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
8 changes: 0 additions & 8 deletions src/db/add_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,6 @@ pub(crate) fn add_package_into_database(
add_owners_into_database(&conn, &registry_data.owners, crate_id)?;
add_compression_into_database(&conn, compression_algorithms.into_iter(), release_id)?;

// Update the crates table with the new release
conn.execute(
"UPDATE crates
SET latest_version_id = $2
WHERE id = $1",
&[&crate_id, &release_id],
)?;

Ok(release_id)
}

Expand Down
11 changes: 11 additions & 0 deletions src/db/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,17 @@ pub fn migrate(version: Option<Version>, conn: &Connection) -> CratesfyiResult<(
"DROP TABLE compression_rels;
ALTER TABLE files DROP COLUMN compression;"
),
migration!(
context,
// version
15,
// description
"Remove unused latest_version_id column",
// upgrade query
"ALTER TABLE crates DROP COLUMN latest_version_id;",
// downgrade query
"ALTER TABLE crates ADD COLUMN latest_version_id INT DEFAULT 0;",
)
];

for migration in migrations {
Expand Down