mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
db: Add mediums and albums
This commit is contained in:
parent
3eed04d04b
commit
3ab0332475
4 changed files with 152 additions and 7 deletions
|
|
@ -260,7 +260,7 @@ impl Recording {
|
|||
.collect::<Result<Vec<Ensemble>>>()?;
|
||||
|
||||
let tracks: Vec<Track> = tracks::table
|
||||
.order(tracks::sequence_number)
|
||||
.order(tracks::recording_index)
|
||||
.filter(tracks::recording_id.eq(&data.recording_id))
|
||||
.select(tables::Track::as_select())
|
||||
.load::<tables::Track>(connection)?
|
||||
|
|
|
|||
|
|
@ -1,5 +1,32 @@
|
|||
// @generated automatically by Diesel CLI.
|
||||
|
||||
diesel::table! {
|
||||
album_mediums (album_id, medium_id) {
|
||||
album_id -> Text,
|
||||
medium_id -> Text,
|
||||
sequence_number -> Integer,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
album_recordings (album_id, recording_id) {
|
||||
album_id -> Text,
|
||||
recording_id -> Text,
|
||||
sequence_number -> Integer,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
albums (album_id) {
|
||||
album_id -> Text,
|
||||
name -> Text,
|
||||
created_at -> Timestamp,
|
||||
edited_at -> Timestamp,
|
||||
last_used_at -> Timestamp,
|
||||
last_played_at -> Nullable<Timestamp>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
ensemble_persons (ensemble_id, person_id, instrument_id) {
|
||||
ensemble_id -> Text,
|
||||
|
|
@ -31,6 +58,17 @@ diesel::table! {
|
|||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
mediums (medium_id) {
|
||||
medium_id -> Text,
|
||||
discid -> Text,
|
||||
created_at -> Timestamp,
|
||||
edited_at -> Timestamp,
|
||||
last_used_at -> Timestamp,
|
||||
last_played_at -> Nullable<Timestamp>,
|
||||
}
|
||||
}
|
||||
|
||||
diesel::table! {
|
||||
persons (person_id) {
|
||||
person_id -> Text,
|
||||
|
|
@ -95,7 +133,9 @@ diesel::table! {
|
|||
tracks (track_id) {
|
||||
track_id -> Text,
|
||||
recording_id -> Text,
|
||||
sequence_number -> Integer,
|
||||
recording_index -> Integer,
|
||||
medium_id -> Nullable<Text>,
|
||||
medium_index -> Nullable<Integer>,
|
||||
path -> Text,
|
||||
created_at -> Timestamp,
|
||||
edited_at -> Timestamp,
|
||||
|
|
@ -143,6 +183,10 @@ diesel::table! {
|
|||
}
|
||||
}
|
||||
|
||||
diesel::joinable!(album_mediums -> albums (album_id));
|
||||
diesel::joinable!(album_mediums -> mediums (medium_id));
|
||||
diesel::joinable!(album_recordings -> albums (album_id));
|
||||
diesel::joinable!(album_recordings -> recordings (recording_id));
|
||||
diesel::joinable!(ensemble_persons -> ensembles (ensemble_id));
|
||||
diesel::joinable!(ensemble_persons -> instruments (instrument_id));
|
||||
diesel::joinable!(ensemble_persons -> persons (person_id));
|
||||
|
|
@ -156,6 +200,7 @@ diesel::joinable!(recording_persons -> roles (role_id));
|
|||
diesel::joinable!(recordings -> works (work_id));
|
||||
diesel::joinable!(track_works -> tracks (track_id));
|
||||
diesel::joinable!(track_works -> works (work_id));
|
||||
diesel::joinable!(tracks -> mediums (medium_id));
|
||||
diesel::joinable!(tracks -> recordings (recording_id));
|
||||
diesel::joinable!(work_instruments -> instruments (instrument_id));
|
||||
diesel::joinable!(work_instruments -> works (work_id));
|
||||
|
|
@ -164,9 +209,13 @@ diesel::joinable!(work_persons -> roles (role_id));
|
|||
diesel::joinable!(work_persons -> works (work_id));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
album_mediums,
|
||||
album_recordings,
|
||||
albums,
|
||||
ensemble_persons,
|
||||
ensembles,
|
||||
instruments,
|
||||
mediums,
|
||||
persons,
|
||||
recording_ensembles,
|
||||
recording_persons,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,9 @@ pub struct RecordingEnsemble {
|
|||
pub struct Track {
|
||||
pub track_id: String,
|
||||
pub recording_id: String,
|
||||
pub sequence_number: i32,
|
||||
pub recording_index: i32,
|
||||
pub medium_id: Option<String>,
|
||||
pub medium_index: Option<i32>,
|
||||
pub path: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub edited_at: NaiveDateTime,
|
||||
|
|
@ -144,3 +146,41 @@ pub struct TrackWork {
|
|||
pub work_id: String,
|
||||
pub sequence_number: i32,
|
||||
}
|
||||
|
||||
#[derive(Insertable, Queryable, Selectable, Clone, Debug)]
|
||||
#[diesel(check_for_backend(Sqlite))]
|
||||
pub struct Medium {
|
||||
pub medium_id: String,
|
||||
pub discid: String,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub edited_at: NaiveDateTime,
|
||||
pub last_used_at: NaiveDateTime,
|
||||
pub last_played_at: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Insertable, Queryable, Selectable, Clone, Debug)]
|
||||
#[diesel(check_for_backend(Sqlite))]
|
||||
pub struct Album {
|
||||
pub album_id: String,
|
||||
pub name: TranslatedString,
|
||||
pub created_at: NaiveDateTime,
|
||||
pub edited_at: NaiveDateTime,
|
||||
pub last_used_at: NaiveDateTime,
|
||||
pub last_played_at: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Insertable, Queryable, Selectable, Clone, Debug)]
|
||||
#[diesel(check_for_backend(Sqlite))]
|
||||
pub struct AlbumRecording {
|
||||
pub album_id: String,
|
||||
pub recording_id: String,
|
||||
pub sequence_number: i32,
|
||||
}
|
||||
|
||||
#[derive(Insertable, Queryable, Selectable, Clone, Debug)]
|
||||
#[diesel(check_for_backend(Sqlite))]
|
||||
pub struct AlbumMedium {
|
||||
pub album_id: String,
|
||||
pub medium_id: String,
|
||||
pub sequence_number: i32,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue