diff --git a/migrations/2022-08-18-152941_links-column/down.sql b/migrations/2022-08-18-152941_links-column/down.sql new file mode 100644 index 00000000000..c8e85ce14d0 --- /dev/null +++ b/migrations/2022-08-18-152941_links-column/down.sql @@ -0,0 +1,2 @@ +ALTER TABLE versions + DROP COLUMN links; diff --git a/migrations/2022-08-18-152941_links-column/up.sql b/migrations/2022-08-18-152941_links-column/up.sql new file mode 100644 index 00000000000..620022180c2 --- /dev/null +++ b/migrations/2022-08-18-152941_links-column/up.sql @@ -0,0 +1,2 @@ +ALTER TABLE versions + ADD COLUMN links VARCHAR NULL; diff --git a/src/controllers/krate/publish.rs b/src/controllers/krate/publish.rs index f8088c6c88c..81b444c968d 100644 --- a/src/controllers/krate/publish.rs +++ b/src/controllers/krate/publish.rs @@ -171,6 +171,7 @@ pub fn publish(req: &mut dyn RequestExt) -> EndpointResult { file_length as i32, user.id, hex_cksum.clone(), + links.clone(), )? .save(&conn, &verified_email_address)?; diff --git a/src/downloads_counter.rs b/src/downloads_counter.rs index 145db8c7fca..1aee907c1b5 100644 --- a/src/downloads_counter.rs +++ b/src/downloads_counter.rs @@ -458,6 +458,7 @@ mod tests { 0, self.user.id, "0000000000000000000000000000000000000000000000000000000000000000".to_string(), + None, ) .expect("failed to create version") .save(conn, "ghost@example.com") diff --git a/src/models/version.rs b/src/models/version.rs index 172bfb51f34..79420c1952e 100644 --- a/src/models/version.rs +++ b/src/models/version.rs @@ -24,6 +24,7 @@ pub struct Version { pub crate_size: Option, pub published_by: Option, pub checksum: Option, + pub links: Option, } #[derive(Insertable, Debug)] @@ -36,6 +37,7 @@ pub struct NewVersion { crate_size: Option, published_by: i32, checksum: String, + links: Option, } /// The highest version (semver order) and the most recently updated version. @@ -133,6 +135,7 @@ impl NewVersion { crate_size: i32, published_by: i32, checksum: String, + links: Option, ) -> AppResult { let features = serde_json::to_value(features)?; @@ -144,6 +147,7 @@ impl NewVersion { crate_size: Some(crate_size), published_by, checksum, + links, }; new_version.validate_license(license_file)?; diff --git a/src/schema.rs b/src/schema.rs index 38f59b598f8..00254915d10 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -994,6 +994,12 @@ table! { /// /// (Automatically generated by Diesel.) checksum -> Nullable, + /// The `links` column of the `versions` table. + /// + /// Its SQL type is `Nullable`. + /// + /// (Automatically generated by Diesel.) + links -> Nullable, } } diff --git a/src/tests/builders/version.rs b/src/tests/builders/version.rs index 78eadfaf678..9f6164a09de 100644 --- a/src/tests/builders/version.rs +++ b/src/tests/builders/version.rs @@ -19,6 +19,7 @@ pub struct VersionBuilder<'a> { size: i32, yanked: bool, checksum: String, + links: Option, } impl<'a> VersionBuilder<'a> { @@ -43,6 +44,7 @@ impl<'a> VersionBuilder<'a> { size: 0, yanked: false, checksum: String::new(), + links: None, } } @@ -94,6 +96,7 @@ impl<'a> VersionBuilder<'a> { self.size, published_by, self.checksum, + self.links, )? .save(connection, "someone@example.com")?; diff --git a/src/worker/dump_db/dump-db.toml b/src/worker/dump_db/dump-db.toml index b20cdeb0df1..8a1575135da 100644 --- a/src/worker/dump_db/dump-db.toml +++ b/src/worker/dump_db/dump-db.toml @@ -214,6 +214,7 @@ license = "public" crate_size = "public" published_by = "public" checksum = "public" +links = "public" [versions_published_by.columns] version_id = "private" diff --git a/src/worker/update_downloads.rs b/src/worker/update_downloads.rs index d4c4730208a..be5b5874a11 100644 --- a/src/worker/update_downloads.rs +++ b/src/worker/update_downloads.rs @@ -109,6 +109,7 @@ mod test { 0, user_id, "0000000000000000000000000000000000000000000000000000000000000000".to_string(), + None, ) .unwrap(); let version = version.save(conn, "someone@example.com").unwrap();