diff --git a/Lesson4/step2/database_setup.py b/Lesson4/step2/database_setup.py index f49c971..a5ec291 100644 --- a/Lesson4/step2/database_setup.py +++ b/Lesson4/step2/database_setup.py @@ -1,6 +1,6 @@ from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy.orm import relationship +from sqlalchemy.orm import relationship, backref from sqlalchemy import create_engine Base = declarative_base() @@ -41,7 +41,7 @@ class MenuItem(Base): price = Column(String(8)) course = Column(String(250)) restaurant_id = Column(Integer, ForeignKey('restaurant.id')) - restaurant = relationship(Restaurant) + restaurant = relationship(Restaurant, backref=backref("items", cascade="all,delete")) user_id = Column(Integer, ForeignKey('user.id')) user = relationship(User)