From cf3ea4807698f3ff84ee37b07e8735b1d8f8b59c Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Sun, 18 Sep 2022 18:49:03 +0000 Subject: [PATCH] remove unused tracklist entity --- Cargo.lock | 4 +-- Cargo.toml | 4 +-- entity/Cargo.toml | 2 +- entity/src/lib.rs | 1 - entity/src/track.rs | 13 -------- entity/src/tracklist.rs | 22 ------------- migration/Cargo.toml | 2 +- .../src/m20220101_000001_create_table.rs | 33 ------------------- playback/Cargo.toml | 2 +- scanner/Cargo.toml | 2 +- server/src/library.rs | 1 - tracklist/Cargo.toml | 2 +- 12 files changed, 9 insertions(+), 79 deletions(-) delete mode 100644 entity/src/tracklist.rs diff --git a/Cargo.lock b/Cargo.lock index 0d52fb7..5eb1eda 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1573,14 +1573,14 @@ version = "0.1.0" [[package]] name = "music-player-entity" -version = "0.1.1" +version = "0.1.2" dependencies = [ "sea-orm", ] [[package]] name = "music-player-migration" -version = "0.1.0" +version = "0.1.1" dependencies = [ "dotenv", "music-player-settings", diff --git a/Cargo.toml b/Cargo.toml index 66fc1f9..a01bf4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,11 +32,11 @@ version = "0.1.1" [dependencies.music-player-entity] path = "entity" -version = "0.1.1" +version = "0.1.2" [dependencies.music-player-migration] path = "migration" -version = "0.1.0" +version = "0.1.1" [dependencies.music-player-settings] path = "settings" diff --git a/entity/Cargo.toml b/entity/Cargo.toml index 4fb1ba8..a68411b 100644 --- a/entity/Cargo.toml +++ b/entity/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "music-player-entity" -version = "0.1.1" +version = "0.1.2" edition = "2021" repository = "https://github.com/tsirysndr/music-player" license = "MIT" diff --git a/entity/src/lib.rs b/entity/src/lib.rs index 45a4053..90a1088 100644 --- a/entity/src/lib.rs +++ b/entity/src/lib.rs @@ -4,4 +4,3 @@ pub mod artist; pub mod playlist; pub mod playlist_tracks; pub mod track; -pub mod tracklist; diff --git a/entity/src/track.rs b/entity/src/track.rs index 5117004..7027180 100644 --- a/entity/src/track.rs +++ b/entity/src/track.rs @@ -18,7 +18,6 @@ pub struct Model { pub duration: Option, pub uri: String, pub album_id: Option, - pub tracklist_id: Option, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] @@ -29,12 +28,6 @@ pub enum Relation { to = "super::album::Column::Id" )] Album, - #[sea_orm( - belongs_to = "super::tracklist::Entity", - from = "Column::TracklistId", - to = "super::tracklist::Column::Id" - )] - Tracklist, } impl Related for Entity { @@ -43,12 +36,6 @@ impl Related for Entity { } } -impl Related for Entity { - fn to() -> RelationDef { - Relation::Tracklist.def() - } -} - impl Related for Entity { fn to() -> RelationDef { super::playlist_tracks::Relation::Playlist.def() diff --git a/entity/src/tracklist.rs b/entity/src/tracklist.rs deleted file mode 100644 index 925e72b..0000000 --- a/entity/src/tracklist.rs +++ /dev/null @@ -1,22 +0,0 @@ -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel)] -#[sea_orm(table_name = "tracklist")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: String, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::track::Entity")] - Track, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Track.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/migration/Cargo.toml b/migration/Cargo.toml index 54b4f0b..a362bb2 100644 --- a/migration/Cargo.toml +++ b/migration/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "music-player-migration" -version = "0.1.0" +version = "0.1.1" edition = "2021" repository = "https://github.com/tsirysndr/music-player" license = "MIT" diff --git a/migration/src/m20220101_000001_create_table.rs b/migration/src/m20220101_000001_create_table.rs index e159a52..e1be5b1 100644 --- a/migration/src/m20220101_000001_create_table.rs +++ b/migration/src/m20220101_000001_create_table.rs @@ -56,7 +56,6 @@ impl MigrationTrait for Migration { .col(ColumnDef::new(Track::Duration).float()) .col(ColumnDef::new(Track::Uri).string()) .col(ColumnDef::new(Track::AlbumId).string()) - .col(ColumnDef::new(Track::TracklistId).string()) .foreign_key( ForeignKeyCreateStatement::new() .name("track_album_id_fkey") @@ -66,15 +65,6 @@ impl MigrationTrait for Migration { .to_col(Album::Id) .on_delete(ForeignKeyAction::Cascade), ) - .foreign_key( - ForeignKeyCreateStatement::new() - .name("track_tracklist_id_fkey") - .from_tbl(Track::Table) - .from_col(Track::TracklistId) - .to_tbl(Tracklist::Table) - .to_col(Tracklist::Id) - .on_delete(ForeignKeyAction::Cascade), - ) .to_owned(), ) .await?; @@ -93,20 +83,6 @@ impl MigrationTrait for Migration { .to_owned(), ) .await?; - manager - .create_table( - Table::create() - .table(Tracklist::Table) - .if_not_exists() - .col( - ColumnDef::new(Tracklist::Id) - .string() - .not_null() - .primary_key(), - ) - .to_owned(), - ) - .await?; manager .create_table( Table::create() @@ -176,9 +152,6 @@ impl MigrationTrait for Migration { manager .drop_table(Table::drop().table(Playlist::Table).if_exists().to_owned()) .await?; - manager - .drop_table(Table::drop().table(Tracklist::Table).if_exists().to_owned()) - .await?; manager .drop_table(Table::drop().table(Addon::Table).if_exists().to_owned()) .await?; @@ -237,12 +210,6 @@ enum Playlist { Name, } -#[derive(Iden)] -enum Tracklist { - Table, - Id, -} - #[derive(Iden)] enum Addon { Table, diff --git a/playback/Cargo.toml b/playback/Cargo.toml index 7bd9cde..7c8a549 100644 --- a/playback/Cargo.toml +++ b/playback/Cargo.toml @@ -15,7 +15,7 @@ version = "0.1.0" [dependencies.music-player-entity] path = "../entity" -version = "0.1.1" +version = "0.1.2" [dependencies] cpal = "0.13.0" diff --git a/scanner/Cargo.toml b/scanner/Cargo.toml index cb517aa..c742ff2 100644 --- a/scanner/Cargo.toml +++ b/scanner/Cargo.toml @@ -15,7 +15,7 @@ version = "0.1.0" [dependencies.music-player-entity] path = "../entity" -version = "0.1.1" +version = "0.1.2" [dependencies.music-player-storage] path = "../storage" diff --git a/server/src/library.rs b/server/src/library.rs index 6a4bfc1..d381c59 100644 --- a/server/src/library.rs +++ b/server/src/library.rs @@ -77,7 +77,6 @@ impl LibraryService for Library { "{:x}", md5::compute(format!("{}{}", song.album, song.artist)) ))), - tracklist_id: ActiveValue::Set(None), }; match item.insert(db.get_connection()).await { diff --git a/tracklist/Cargo.toml b/tracklist/Cargo.toml index b06c8c7..30ae2cd 100644 --- a/tracklist/Cargo.toml +++ b/tracklist/Cargo.toml @@ -12,7 +12,7 @@ description = "The tracklist manager for the music player" [dependencies.music-player-entity] path = "../entity" -version = "0.1.1" +version = "0.1.2" [dependencies] atlist-rs = "0.2.1"