Update db schema to include ReplayGain

This commit is contained in:
Agatha Lovelace 2024-02-21 17:37:32 +01:00
parent 45d16d8487
commit 9039cc8f75
Signed by: sorceress
GPG Key ID: 01D0B3AB10CED4F8
6 changed files with 24 additions and 10 deletions

View File

@ -30,6 +30,10 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Song::Genres).string()) .col(ColumnDef::new(Song::Genres).string())
.col(ColumnDef::new(Song::Track).integer()) .col(ColumnDef::new(Song::Track).integer())
.col(ColumnDef::new(Song::Year).integer()) .col(ColumnDef::new(Song::Year).integer())
.col(ColumnDef::new(Song::RGTrackGain).double())
.col(ColumnDef::new(Song::RGTrackPeak).double())
.col(ColumnDef::new(Song::RGAlbumGain).double())
.col(ColumnDef::new(Song::RGAlbumPeak).double())
.to_owned(), .to_owned(),
) )
.await .await
@ -55,6 +59,7 @@ pub enum Song {
SourceId, SourceId,
/// A hash of the song's samples as Vec<f32> /// A hash of the song's samples as Vec<f32>
Hash, Hash,
/// Track artist
Artist, Artist,
AlbumArtist, AlbumArtist,
Name, Name,
@ -65,4 +70,8 @@ pub enum Song {
/// Number of the track in the album /// Number of the track in the album
Track, Track,
Year, Year,
RGTrackGain,
RGTrackPeak,
RGAlbumGain,
RGAlbumPeak,
} }

View File

@ -1,8 +1,7 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
/// An audio track
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
#[sea_orm(table_name = "library")] #[sea_orm(table_name = "library")]
pub struct Model { pub struct Model {
@ -12,9 +11,7 @@ pub struct Model {
pub filename: String, pub filename: String,
pub source_id: i32, pub source_id: i32,
pub hash: u32, pub hash: u32,
// TODO: should be many-to-many
pub artist: Option<String>, pub artist: Option<String>,
// TODO: should be many-to-many
pub album_artist: Option<String>, pub album_artist: Option<String>,
pub name: Option<String>, pub name: Option<String>,
pub album: Option<String>, pub album: Option<String>,
@ -22,6 +19,14 @@ pub struct Model {
pub genres: Option<String>, pub genres: Option<String>,
pub track: Option<i32>, pub track: Option<i32>,
pub year: Option<i32>, pub year: Option<i32>,
#[sea_orm(column_type = "Double", nullable)]
pub rg_track_gain: Option<f64>,
#[sea_orm(column_type = "Double", nullable)]
pub rg_track_peak: Option<f64>,
#[sea_orm(column_type = "Double", nullable)]
pub rg_album_gain: Option<f64>,
#[sea_orm(column_type = "Double", nullable)]
pub rg_album_peak: Option<f64>,
} }
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@ -1,4 +1,4 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
pub mod prelude; pub mod prelude;

View File

@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "playlist_entries")] #[sea_orm(table_name = "playlist_entries")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,8 +1,8 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
use sea_orm::entity::prelude::*; use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "playlists")] #[sea_orm(table_name = "playlists")]
pub struct Model { pub struct Model {
#[sea_orm(primary_key)] #[sea_orm(primary_key)]

View File

@ -1,4 +1,4 @@
//! SeaORM Entity. Generated by sea-orm-codegen 0.9.1 //! `SeaORM` Entity. Generated by sea-orm-codegen 0.12.2
pub use super::library::Entity as Library; pub use super::library::Entity as Library;
pub use super::playlist_entries::Entity as PlaylistEntries; pub use super::playlist_entries::Entity as PlaylistEntries;