diff --git a/docker-compose_dev.yml b/docker-compose_dev.yml index ac3c228..60d71ec 100644 --- a/docker-compose_dev.yml +++ b/docker-compose_dev.yml @@ -14,7 +14,7 @@ services: POSTGRES_USER: kalkutago POSTGRES_DB: kalkutago POSTGRES_HOST: database - secrets: [ postgres-password, cookie-secret ] + secrets: [ postgres-password ] depends_on: [ database ] expose: [ 8000 ] # ports: @@ -25,7 +25,6 @@ services: labels: traefik.enable: true traefik.http.routers.kalkutago_server.rule: 'Host(`kalkutago`) && PathPrefix(`/api`)' - database: image: postgres environment: diff --git a/server/src/entities/mod.rs b/server/src/entities/mod.rs index 2facb82..e9e8598 100644 --- a/server/src/entities/mod.rs +++ b/server/src/entities/mod.rs @@ -7,4 +7,3 @@ pub mod ticks; pub mod track2_groups; pub mod tracks; pub mod user; -pub mod user_tracks; diff --git a/server/src/entities/prelude.rs b/server/src/entities/prelude.rs index ee9de0e..419d754 100644 --- a/server/src/entities/prelude.rs +++ b/server/src/entities/prelude.rs @@ -5,4 +5,3 @@ pub use super::ticks::Entity as Ticks; pub use super::track2_groups::Entity as Track2Groups; pub use super::tracks::Entity as Tracks; pub use super::user::Entity as User; -pub use super::user_tracks::Entity as UserTracks; diff --git a/server/src/entities/tracks.rs b/server/src/entities/tracks.rs index 4b1b7f3..de4cef4 100644 --- a/server/src/entities/tracks.rs +++ b/server/src/entities/tracks.rs @@ -24,8 +24,6 @@ pub enum Relation { Ticks, #[sea_orm(has_many = "super::track2_groups::Entity")] Track2Groups, - #[sea_orm(has_many = "super::user_tracks::Entity")] - UserTracks, } impl Related for Entity { @@ -40,19 +38,4 @@ impl Related for Entity { } } -impl Related for Entity { - fn to() -> RelationDef { - Relation::UserTracks.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - super::user_tracks::Relation::User.def() - } - fn via() -> Option { - Some(super::user_tracks::Relation::Tracks.def().rev()) - } -} - impl ActiveModelBehavior for ActiveModel {} diff --git a/server/src/entities/user.rs b/server/src/entities/user.rs index 7ba561a..0ddc95a 100644 --- a/server/src/entities/user.rs +++ b/server/src/entities/user.rs @@ -25,25 +25,7 @@ pub struct Model { } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm(has_many = "super::user_tracks::Entity")] - UserTracks, -} -impl Related for Entity { - fn to() -> RelationDef { - Relation::UserTracks.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - super::user_tracks::Relation::Tracks.def() - } - - fn via() -> Option { - Some(super::user_tracks::Relation::User.def().rev()) - } -} +pub enum Relation {} impl ActiveModelBehavior for ActiveModel {} diff --git a/server/src/entities/user_tracks.rs b/server/src/entities/user_tracks.rs deleted file mode 100644 index 45214d7..0000000 --- a/server/src/entities/user_tracks.rs +++ /dev/null @@ -1,46 +0,0 @@ -//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.3 - -use sea_orm::entity::prelude::*; - -#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] -#[sea_orm(table_name = "user_tracks")] -pub struct Model { - #[sea_orm(primary_key)] - pub id: i32, - pub user_id: i32, - pub track_id: i32, -} - -#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] -pub enum Relation { - #[sea_orm( - belongs_to = "super::tracks::Entity", - from = "Column::TrackId", - to = "super::tracks::Column::Id", - on_update = "NoAction", - on_delete = "NoAction" - )] - Tracks, - #[sea_orm( - belongs_to = "super::user::Entity", - from = "Column::UserId", - to = "super::user::Column::Id", - on_update = "NoAction", - on_delete = "NoAction" - )] - User, -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::Tracks.def() - } -} - -impl Related for Entity { - fn to() -> RelationDef { - Relation::User.def() - } -} - -impl ActiveModelBehavior for ActiveModel {} diff --git a/server/src/migrator/m20230626_083036_create_users_table.rs b/server/src/migrator/m20230626_083036_create_users_table.rs index 6c8e7b7..50ab989 100644 --- a/server/src/migrator/m20230626_083036_create_users_table.rs +++ b/server/src/migrator/m20230626_083036_create_users_table.rs @@ -34,7 +34,7 @@ impl MigrationTrait for Migration { /// Learn more at https://docs.rs/sea-query#iden #[derive(Iden)] -pub(crate) enum User { +enum User { Table, Id, Name, diff --git a/server/src/migrator/m20230626_150551_associate_users_and_tracks.rs b/server/src/migrator/m20230626_150551_associate_users_and_tracks.rs deleted file mode 100644 index 186de49..0000000 --- a/server/src/migrator/m20230626_150551_associate_users_and_tracks.rs +++ /dev/null @@ -1,57 +0,0 @@ -use super::{ - m20230606_000001_create_tracks_table::Tracks, m20230626_083036_create_users_table::User, -}; -use sea_orm_migration::prelude::*; - -#[derive(DeriveMigrationName)] -pub struct Migration; - -#[async_trait::async_trait] -impl MigrationTrait for Migration { - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .create_table( - Table::create() - .table(UserTracks::Table) - .if_not_exists() - .col( - ColumnDef::new(UserTracks::Id) - .integer() - .not_null() - .primary_key() - .auto_increment(), - ) - .col(ColumnDef::new(UserTracks::UserId).integer().not_null()) - .col(ColumnDef::new(UserTracks::TrackId).integer().not_null()) - .foreign_key( - ForeignKey::create() - .name("fk-user_tracks-user_id") - .from(UserTracks::Table, UserTracks::UserId) - .to(User::Table, User::Id), - ) - .foreign_key( - ForeignKey::create() - .name("fk-user_tracks-track_id") - .from(UserTracks::Table, UserTracks::TrackId) - .to(Tracks::Table, Tracks::Id), - ) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .drop_table(Table::drop().table(UserTracks::Table).to_owned()) - .await - } -} - -/// Learn more at https://docs.rs/sea-query#iden -#[derive(Iden)] -enum UserTracks { - Table, - Id, - UserId, - TrackId, -} diff --git a/server/src/migrator/mod.rs b/server/src/migrator/mod.rs index edf6a1f..6d4f915 100644 --- a/server/src/migrator/mod.rs +++ b/server/src/migrator/mod.rs @@ -3,7 +3,6 @@ mod m20230606_000002_create_ticks_table; mod m20230606_000003_create_groups_table; mod m20230606_000004_create_track2groups_table; mod m20230626_083036_create_users_table; -mod m20230626_150551_associate_users_and_tracks; use sea_orm_migration::prelude::*; @@ -18,7 +17,6 @@ impl MigratorTrait for Migrator { Box::new(m20230606_000003_create_groups_table::Migration), Box::new(m20230606_000004_create_track2groups_table::Migration), Box::new(m20230626_083036_create_users_table::Migration), - Box::new(m20230626_150551_associate_users_and_tracks::Migration), ] } }