Remove support for separate part composers

This commit is contained in:
Elias Projahn 2021-02-07 10:02:30 +01:00
parent aeed44248e
commit fdc5bc72a8
5 changed files with 10 additions and 109 deletions

View file

@ -25,8 +25,7 @@ CREATE TABLE "work_parts" (
"id" BIGINT NOT NULL PRIMARY KEY,
"work" TEXT NOT NULL REFERENCES "works"("id") ON DELETE CASCADE,
"part_index" BIGINT NOT NULL,
"title" TEXT NOT NULL,
"composer" TEXT REFERENCES "persons"("id")
"title" TEXT NOT NULL
);
CREATE TABLE "work_sections" (

View file

@ -79,7 +79,6 @@ table! {
work -> Text,
part_index -> BigInt,
title -> Text,
composer -> Nullable<Text>,
}
}
@ -110,7 +109,6 @@ joinable!(recordings -> works (work));
joinable!(track_sets -> mediums (medium));
joinable!(track_sets -> recordings (recording));
joinable!(tracks -> track_sets (track_set));
joinable!(work_parts -> persons (composer));
joinable!(work_parts -> works (work));
joinable!(work_sections -> works (work));
joinable!(works -> persons (composer));

View file

@ -41,7 +41,6 @@ struct WorkPartRow {
pub work: String,
pub part_index: i64,
pub title: String,
pub composer: Option<String>,
}
/// Table row data for a work section.
@ -58,7 +57,6 @@ struct WorkSectionRow {
#[serde(rename_all = "camelCase")]
pub struct WorkPart {
pub title: String,
pub composer: Option<Person>,
}
/// A heading between work parts.
@ -123,14 +121,6 @@ impl Database {
}
}
for part in &work.parts {
if let Some(person) = &part.composer {
if self.get_person(&person.id)?.is_none() {
self.update_person(person.clone())?;
}
}
}
// Add the actual work.
let row: WorkRow = work.clone().into();
@ -163,7 +153,6 @@ impl Database {
work: work_id.to_string(),
part_index: index as i64,
title: part.title,
composer: part.composer.map(|person| person.id),
};
diesel::insert_into(work_parts::table)
@ -237,17 +226,6 @@ impl Database {
for part_row in part_rows {
parts.push(WorkPart {
title: part_row.title,
composer: match part_row.composer {
Some(composer) => Some(
self.get_person(&composer)?
.ok_or(Error::Other(format!(
"Failed to get person ({}) for work ({}).",
composer,
row.id,
)))?
),
None => None,
},
});
}