update foods and units for multitenant support

This commit is contained in:
Hayden
2022-02-08 14:55:18 -09:00
parent fbc17b670d
commit 9a82a172cb
11 changed files with 194 additions and 15 deletions

View File

@@ -55,6 +55,10 @@ class Group(SqlAlchemyBase, BaseMixins):
group_reports = orm.relationship("ReportModel", **common_args)
group_event_notifiers = orm.relationship("GroupEventNotifierModel", **common_args)
# Owned Models
ingredient_units = orm.relationship("IngredientUnitModel", **common_args)
ingredient_foods = orm.relationship("IngredientFoodModel", **common_args)
class Config:
exclude = {
"users",

View File

@@ -9,6 +9,11 @@ from .._model_utils.guid import GUID
class IngredientUnitModel(SqlAlchemyBase, BaseMixins):
__tablename__ = "ingredient_units"
# ID Relationships
group_id = Column(GUID, ForeignKey("groups.id"), nullable=False)
group = orm.relationship("Group", back_populates="ingredient_units", foreign_keys=[group_id])
id = Column(Integer, primary_key=True)
name = Column(String)
description = Column(String)
@@ -23,6 +28,11 @@ class IngredientUnitModel(SqlAlchemyBase, BaseMixins):
class IngredientFoodModel(SqlAlchemyBase, BaseMixins):
__tablename__ = "ingredient_foods"
# ID Relationships
group_id = Column(GUID, ForeignKey("groups.id"), nullable=False)
group = orm.relationship("Group", back_populates="ingredient_foods", foreign_keys=[group_id])
id = Column(Integer, primary_key=True)
name = Column(String)
description = Column(String)