Merge pull request #136 from modrinth/small-fixes

Fix version number editing
This commit is contained in:
Geometrically 2021-01-15 08:18:15 -07:00 committed by GitHub
commit 68517c15f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -1236,6 +1236,19 @@
"nullable": []
}
},
"53a8966ac345cc334ad65ea907be81af74e90b1217696c7eedcf8a8e3fca736e": {
"query": "\n UPDATE versions\n SET version_number = $1\n WHERE (id = $2)\n ",
"describe": {
"columns": [],
"parameters": {
"Left": [
"Varchar",
"Int8"
]
},
"nullable": []
}
},
"5564434408e4b88ff1bdd14e0d32a35136e5ee0c837655fbde7d3ca9182dc25b": {
"query": "\n SELECT tm.id, tm.team_id, tm.user_id, tm.role, tm.permissions, tm.accepted FROM mods m\n INNER JOIN team_members tm ON tm.team_id = m.team_id AND user_id = $2 AND accepted = TRUE\n WHERE m.id = $1\n ",
"describe": {

View File

@ -206,6 +206,7 @@ fn convert_version(data: database::models::version_item::QueryVersion) -> models
#[derive(Serialize, Deserialize)]
pub struct EditVersion {
pub name: Option<String>,
pub version_number: Option<String>,
pub changelog: Option<String>,
pub version_type: Option<models::mods::VersionType>,
pub dependencies: Option<Vec<models::ids::VersionId>>,
@ -298,6 +299,21 @@ pub async fn version_edit(
.map_err(|e| ApiError::DatabaseError(e.into()))?;
}
if let Some(number) = &new_version.version_number {
sqlx::query!(
"
UPDATE versions
SET version_number = $1
WHERE (id = $2)
",
number,
id as database::models::ids::VersionId,
)
.execute(&mut *transaction)
.await
.map_err(|e| ApiError::DatabaseError(e.into()))?;
}
if let Some(version_type) = &new_version.version_type {
let channel = database::models::ids::ChannelId::get_id(
version_type.as_str(),