diff --git a/tests/bakery_chain/lineitem.rs b/tests/bakery_chain/lineitem.rs index bae11cf2..f4c9e3b6 100644 --- a/tests/bakery_chain/lineitem.rs +++ b/tests/bakery_chain/lineitem.rs @@ -62,12 +62,12 @@ impl RelationTrait for Relation { fn def(&self) -> RelationDef { match self { Self::Order => Entity::belongs_to(super::order::Entity) - .from(Column::Id) - .to(super::order::Column::CustomerId) + .from(Column::OrderId) + .to(super::order::Column::Id) .into(), Self::Cake => Entity::belongs_to(super::cake::Entity) - .from(Column::Id) - .to(super::cake::Column::LineitemId) + .from(Column::CakeId) + .to(super::cake::Column::Id) .into(), } } diff --git a/tests/schema/mod.rs b/tests/schema/mod.rs index 2841066c..b0536873 100644 --- a/tests/schema/mod.rs +++ b/tests/schema/mod.rs @@ -132,6 +132,11 @@ pub async fn create_lineitem_table(db: &DbConn) -> Result { .integer() .not_null(), ) + .col( + ColumnDef::new(lineitem::Column::CakeId) + .integer() + .not_null(), + ) .foreign_key( ForeignKey::create() .name("FK_lineitem_order") @@ -140,6 +145,14 @@ pub async fn create_lineitem_table(db: &DbConn) -> Result { .on_delete(ForeignKeyAction::Cascade) .on_update(ForeignKeyAction::Cascade), ) + .foreign_key( + ForeignKey::create() + .name("FK_lineitem_cake") + .from(lineitem::Entity, lineitem::Column::CakeId) + .to(cake::Entity, cake::Column::Id) + .on_delete(ForeignKeyAction::Cascade) + .on_update(ForeignKeyAction::Cascade), + ) .to_owned(); create_table(db, &stmt).await @@ -183,11 +196,6 @@ pub async fn create_cake_table(db: &DbConn) -> Result { .col(ColumnDef::new(cake::Column::Name).string()) .col(ColumnDef::new(cake::Column::Price).float()) .col(ColumnDef::new(cake::Column::BakeryId).integer().not_null()) - .col( - ColumnDef::new(cake::Column::LineitemId) - .integer() - .not_null(), - ) .foreign_key( ForeignKey::create() .name("FK_cake_bakery")