Skip to content

Commit f2a7274

Browse files
committed
Add linecount field to Version database model
This adds the `linecounts` field to both the `Version` struct and `NewVersion` builder. The field stores linecount data as `JSON`, following the established pattern for flexible schema evolution without requiring additional migrations. The `linecounts` field is `Optional` to handle existing versions that don't have this data, and will be populated for new versions during the publish process. This design ensures backward compatibility while enabling rich source code metrics for future crate versions.
1 parent 8f4075c commit f2a7274

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

crates/crates_io_database/src/models/version.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub struct Version {
3636
pub homepage: Option<String>,
3737
pub documentation: Option<String>,
3838
pub repository: Option<String>,
39+
pub linecounts: Option<serde_json::Value>,
3940
}
4041

4142
impl Version {
@@ -103,6 +104,7 @@ pub struct NewVersion<'a> {
103104
repository: Option<&'a str>,
104105
categories: Option<&'a [&'a str]>,
105106
keywords: Option<&'a [&'a str]>,
107+
linecounts: Option<serde_json::Value>,
106108
}
107109

108110
impl NewVersion<'_> {

0 commit comments

Comments
 (0)