diff --git a/migrations/2019-08-28-224353_remove_licenses_column_from_crates/down.sql b/migrations/2019-08-28-224353_remove_licenses_column_from_crates/down.sql new file mode 100644 index 00000000000..43f51ae4d94 --- /dev/null +++ b/migrations/2019-08-28-224353_remove_licenses_column_from_crates/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE crates ADD COLUMN license VARCHAR; diff --git a/migrations/2019-08-28-224353_remove_licenses_column_from_crates/up.sql b/migrations/2019-08-28-224353_remove_licenses_column_from_crates/up.sql new file mode 100644 index 00000000000..32b253992ae --- /dev/null +++ b/migrations/2019-08-28-224353_remove_licenses_column_from_crates/up.sql @@ -0,0 +1,3 @@ +-- ALERT! DESTRUCTIVE MIGRATION +-- DO NOT DEPLOY UNTIL PREVIOUS COMMIT IS DEPLOYED +ALTER TABLE crates DROP COLUMN license; diff --git a/src/controllers/krate/publish.rs b/src/controllers/krate/publish.rs index d9be8618a1e..6061e410dc2 100644 --- a/src/controllers/krate/publish.rs +++ b/src/controllers/krate/publish.rs @@ -79,17 +79,12 @@ pub fn publish(req: &mut dyn Request) -> CargoResult { documentation: new_crate.documentation.as_ref().map(|s| &**s), readme: new_crate.readme.as_ref().map(|s| &**s), repository: repo.as_ref().map(String::as_str), - license: new_crate.license.as_ref().map(|s| &**s), max_upload_size: None, }; let license_file = new_crate.license_file.as_ref().map(|s| &**s); - let krate = persist.create_or_update( - &conn, - license_file, - user.id, - Some(&app.config.publish_rate_limit), - )?; + let krate = + persist.create_or_update(&conn, user.id, Some(&app.config.publish_rate_limit))?; let owners = krate.owners(&conn)?; if user.rights(req.app(), &owners)? < Rights::Publish { diff --git a/src/models/krate.rs b/src/models/krate.rs index 327665108be..0a1eba2e7b9 100644 --- a/src/models/krate.rs +++ b/src/models/krate.rs @@ -42,7 +42,6 @@ pub struct Crate { pub description: Option, pub homepage: Option, pub documentation: Option, - pub license: Option, pub repository: Option, pub max_upload_size: Option, } @@ -58,7 +57,6 @@ type AllColumns = ( crates::description, crates::homepage, crates::documentation, - crates::license, crates::repository, crates::max_upload_size, ); @@ -72,7 +70,6 @@ pub const ALL_COLUMNS: AllColumns = ( crates::description, crates::homepage, crates::documentation, - crates::license, crates::repository, crates::max_upload_size, ); @@ -97,20 +94,18 @@ pub struct NewCrate<'a> { pub readme: Option<&'a str>, pub repository: Option<&'a str>, pub max_upload_size: Option, - pub license: Option<&'a str>, } impl<'a> NewCrate<'a> { pub fn create_or_update( mut self, conn: &PgConnection, - license_file: Option<&'a str>, uploader: i32, rate_limit: Option<&PublishRateLimit>, ) -> CargoResult { use diesel::update; - self.validate(license_file)?; + self.validate()?; self.ensure_name_not_reserved(conn)?; conn.transaction(|| { @@ -132,7 +127,7 @@ impl<'a> NewCrate<'a> { }) } - fn validate(&mut self, license_file: Option<&'a str>) -> CargoResult<()> { + fn validate(&mut self) -> CargoResult<()> { fn validate_url(url: Option<&str>, field: &str) -> CargoResult<()> { let url = match url { Some(s) => s, @@ -163,28 +158,6 @@ impl<'a> NewCrate<'a> { validate_url(self.homepage, "homepage")?; validate_url(self.documentation, "documentation")?; validate_url(self.repository, "repository")?; - self.validate_license(license_file)?; - Ok(()) - } - - fn validate_license(&mut self, license_file: Option<&str>) -> CargoResult<()> { - if let Some(license) = self.license { - for part in license.split('/') { - license_exprs::validate_license_expr(part).map_err(|e| { - human(&format_args!( - "{}; see http://opensource.org/licenses \ - for options, and http://spdx.org/licenses/ \ - for their identifiers", - e - )) - })?; - } - } else if license_file.is_some() { - // If no license is given, but a license file is given, flag this - // crate as having a nonstandard license. Note that we don't - // actually do anything else with license_file currently. - self.license = Some("non-standard"); - } Ok(()) } diff --git a/src/models/token.rs b/src/models/token.rs index 1c71d932db5..5765a6e6a51 100644 --- a/src/models/token.rs +++ b/src/models/token.rs @@ -96,5 +96,4 @@ mod tests { .find(r#""last_used_at":"2017-01-06T14:23:12+00:00""#) .is_some()); } - } diff --git a/src/schema.rs b/src/schema.rs index 6fd4bfb22d7..6e4acf19662 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -332,12 +332,6 @@ table! { /// /// (Automatically generated by Diesel.) textsearchable_index_col -> Tsvector, - /// The `license` column of the `crates` table. - /// - /// Its SQL type is `Nullable`. - /// - /// (Automatically generated by Diesel.) - license -> Nullable, /// The `repository` column of the `crates` table. /// /// Its SQL type is `Nullable`. diff --git a/src/tasks/update_downloads.rs b/src/tasks/update_downloads.rs index 2bc63a2bac2..166ad2540d7 100644 --- a/src/tasks/update_downloads.rs +++ b/src/tasks/update_downloads.rs @@ -103,7 +103,7 @@ mod test { name: "foo", ..Default::default() } - .create_or_update(conn, None, user_id, None) + .create_or_update(conn, user_id, None) .unwrap(); let version = NewVersion::new( krate.id, diff --git a/src/tests/builders.rs b/src/tests/builders.rs index 819545f49fb..17c71581f0e 100644 --- a/src/tests/builders.rs +++ b/src/tests/builders.rs @@ -234,7 +234,7 @@ impl<'a> CrateBuilder<'a> { let mut krate = self .krate - .create_or_update(connection, None, self.owner_id, None)?; + .create_or_update(connection, self.owner_id, None)?; // Since we are using `NewCrate`, we can't set all the // crate properties in a single DB call.