Skip to content

Commit 8033e6a

Browse files
author
ebreton
committed
Add subitem
1 parent c0123bb commit 8033e6a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

{{cookiecutter.project_slug}}/backend/app/app/db/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
from app.db.base_class import Base # noqa
44
from app.db_models.user import User # noqa
55
from app.db_models.item import Item # noqa
6+
from app.db_models.subitem import SubItem # noqa

{{cookiecutter.project_slug}}/backend/app/app/db_models/item.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ class Item(Base):
1010
description = Column(String, index=True)
1111
owner_id = Column(Integer, ForeignKey("user.id"))
1212
owner = relationship("User", back_populates="items")
13+
subitems = relationship("SubItem", back_populates="item")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from sqlalchemy import Column, ForeignKey, Integer, String
2+
from sqlalchemy.orm import relationship
3+
4+
from app.db.base_class import Base
5+
6+
7+
class SubItem(Base):
8+
id = Column(Integer, primary_key=True, index=True)
9+
title = Column(String, index=True)
10+
description = Column(String, index=True)
11+
item_id = Column(Integer, ForeignKey("item.id"))
12+
item = relationship("Item", back_populates="subitems")

0 commit comments

Comments
 (0)