Skip to content
Merged
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
4 changes: 2 additions & 2 deletions crates/crates_io_database/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,10 +954,10 @@ diesel::table! {
license -> Nullable<Varchar>,
/// The `crate_size` column of the `versions` table.
///
/// Its SQL type is `Nullable<Int4>`.
/// Its SQL type is `Int4`.
///
/// (Automatically generated by Diesel.)
crate_size -> Nullable<Int4>,
crate_size -> Int4,
/// The `published_by` column of the `versions` table.
///
/// Its SQL type is `Nullable<Int4>`.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table versions
alter column crate_size drop not null;
2 changes: 2 additions & 0 deletions migrations/2024-11-14-094209_make-crate-size-not-null/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table versions
alter column crate_size set not null;
1 change: 1 addition & 0 deletions src/models/default_versions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ mod tests {
versions::num.eq(num),
versions::num_no_build.eq(num),
versions::checksum.eq(""),
versions::crate_size.eq(0),
))
.execute(conn)
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/models/version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Version {
pub features: serde_json::Value,
pub yanked: bool,
pub license: Option<String>,
pub crate_size: Option<i32>,
pub crate_size: i32,
pub published_by: Option<i32>,
pub checksum: String,
pub links: Option<String>,
Expand Down
4 changes: 2 additions & 2 deletions src/tests/routes/crates/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async fn version_size() {
.iter()
.find(|v| v.num == "1.0.0")
.expect("Could not find v1.0.0");
assert_eq!(version1.crate_size, Some(158));
assert_eq!(version1.crate_size, 158);

let version2 = crate_json
.versions
Expand All @@ -140,7 +140,7 @@ async fn version_size() {
.iter()
.find(|v| v.num == "2.0.0")
.expect("Could not find v2.0.0");
assert_eq!(version2.crate_size, Some(184));
assert_eq!(version2.crate_size, 184);
}

#[tokio::test(flavor = "multi_thread")]
Expand Down
1 change: 1 addition & 0 deletions src/tests/worker/rss/sync_crate_feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ async fn create_version(
versions::created_at.eq(publish_time),
versions::updated_at.eq(publish_time),
versions::checksum.eq("checksum"),
versions::crate_size.eq(0),
))
.returning(versions::id)
.get_result(conn)
Expand Down
1 change: 1 addition & 0 deletions src/tests/worker/rss/sync_updates_feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ async fn create_version(
versions::created_at.eq(publish_time),
versions::updated_at.eq(publish_time),
versions::checksum.eq("checksum"),
versions::crate_size.eq(0),
))
.returning(versions::id)
.get_result(conn)
Expand Down
4 changes: 2 additions & 2 deletions src/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ pub struct EncodableVersion {
// NOTE: Used by shields.io, altering `license` requires a PR with shields.io
pub license: Option<String>,
pub links: EncodableVersionLinks,
pub crate_size: Option<i32>,
pub crate_size: i32,
pub published_by: Option<EncodablePublicUser>,
pub audit_actions: Vec<EncodableAuditAction>,
pub checksum: String,
Expand Down Expand Up @@ -763,7 +763,7 @@ mod tests {
version_downloads: "".to_string(),
authors: "".to_string(),
},
crate_size: Some(1234),
crate_size: 1234,
checksum: String::new(),
rust_version: None,
has_lib: None,
Expand Down
1 change: 1 addition & 0 deletions src/worker/jobs/archive_version_downloads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,7 @@ mod tests {
versions::num.eq(num),
versions::num_no_build.eq(num),
versions::checksum.eq(""),
versions::crate_size.eq(0),
))
.returning(versions::id)
.get_result(conn)
Expand Down
1 change: 1 addition & 0 deletions src/worker/jobs/downloads/process_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ mod tests {
versions::num.eq(version),
versions::num_no_build.eq(version),
versions::checksum.eq("checksum"),
versions::crate_size.eq(0),
))
.execute(conn)
.await
Expand Down
1 change: 1 addition & 0 deletions src/worker/jobs/rss/sync_crate_feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ mod tests {
versions::created_at.eq(publish_time),
versions::updated_at.eq(publish_time),
versions::checksum.eq("checksum"),
versions::crate_size.eq(0),
))
.returning(versions::id)
.get_result(conn);
Expand Down
1 change: 1 addition & 0 deletions src/worker/jobs/rss/sync_updates_feed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ mod tests {
versions::created_at.eq(publish_time),
versions::updated_at.eq(publish_time),
versions::checksum.eq("checksum"),
versions::crate_size.eq(0),
))
.returning(versions::id)
.get_result(conn);
Expand Down