mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-02-13 19:33:12 -05:00
* upgrade sqlalchemy to 2.0 * rewrite all db models to sqla 2.0 mapping api * fix some importing and typing weirdness * fix types of a lot of nullable columns * remove get_ref methods * fix issues found by tests * rewrite all queries in repository_recipe to 2.0 style * rewrite all repository queries to 2.0 api * rewrite all remaining queries to 2.0 api * remove now-unneeded __allow_unmapped__ flag * remove and fix some unneeded cases of "# type: ignore" * fix formatting * bump black version * run black * can this please be the last one. okay. just. okay. * fix repository errors * remove return * drop open API validator --------- Co-authored-by: Sören Busch <fleshgolem@gmx.net>
31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy import ForeignKey, String, orm
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from mealie.db.models._model_base import BaseMixins, SqlAlchemyBase
|
|
|
|
from ._model_utils import auto_init
|
|
from ._model_utils.guid import GUID
|
|
|
|
if TYPE_CHECKING:
|
|
from group import Group, ShoppingListItem
|
|
from recipe import IngredientFoodModel
|
|
|
|
|
|
class MultiPurposeLabel(SqlAlchemyBase, BaseMixins):
|
|
__tablename__ = "multi_purpose_labels"
|
|
id: Mapped[GUID] = mapped_column(GUID, default=GUID.generate, primary_key=True)
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False)
|
|
color: Mapped[str] = mapped_column(String(10), nullable=False, default="")
|
|
|
|
group_id: Mapped[GUID] = mapped_column(GUID, ForeignKey("groups.id"), nullable=False, index=True)
|
|
group: Mapped["Group"] = orm.relationship("Group", back_populates="labels")
|
|
|
|
shopping_list_items: Mapped["ShoppingListItem"] = orm.relationship("ShoppingListItem", back_populates="label")
|
|
foods: Mapped["IngredientFoodModel"] = orm.relationship("IngredientFoodModel", back_populates="label")
|
|
|
|
@auto_init()
|
|
def __init__(self, **_) -> None:
|
|
pass
|