mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-12-28 13:05:26 -05:00
feature/multi-tenancy and move caddy server (#980)
* update to GUIDs * fix cookbook id relationships * update webhook keys * cleanup naming and attribute orders * remove old database tables * fix meal-plan images * remove dashbaord and events api * use recipe-id instead of id * cleanup documentation assets * cleanup docs for v1 beta-release * add depends_on for docker-compose * use docker volumes for examples * move caddy to frontend container
This commit is contained in:
@@ -7,7 +7,6 @@ from mealie.repos.repository_factory import AllRepositories
|
||||
from mealie.repos.seed.init_users import default_user_init
|
||||
from mealie.repos.seed.seeders import IngredientFoodsSeeder, IngredientUnitsSeeder, MultiPurposeLabelSeeder
|
||||
from mealie.schema.user.user import GroupBase
|
||||
from mealie.services.events import create_general_event
|
||||
from mealie.services.group_services.group_utils import create_new_group
|
||||
|
||||
logger = root_logger.get_logger("init_db")
|
||||
@@ -62,7 +61,6 @@ def main():
|
||||
else:
|
||||
logger.info("Database Doesn't Exists, Initializing...")
|
||||
init_db(db)
|
||||
create_general_event("Initialize Database", "Initialize database with default values", session)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
from .event import *
|
||||
from .group import *
|
||||
from .labels import *
|
||||
from .recipe.recipe import *
|
||||
from .server import *
|
||||
from .sign_up import *
|
||||
from .users import *
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
from sqlalchemy import Column, DateTime, Integer, String
|
||||
|
||||
from mealie.db.models._model_base import BaseMixins, SqlAlchemyBase
|
||||
|
||||
from ._model_utils import auto_init
|
||||
|
||||
|
||||
class Event(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "events"
|
||||
id = Column(Integer, primary_key=True)
|
||||
title = Column(String)
|
||||
text = Column(String)
|
||||
time_stamp = Column(DateTime)
|
||||
category = Column(String)
|
||||
|
||||
@auto_init()
|
||||
def __init__(self, **_) -> None:
|
||||
pass
|
||||
@@ -7,7 +7,7 @@ from ..recipe.category import Category, cookbooks_to_categories
|
||||
|
||||
class CookBook(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "cookbooks"
|
||||
id = Column(Integer, primary_key=True)
|
||||
id = Column(guid.GUID, primary_key=True, default=guid.GUID.generate)
|
||||
position = Column(Integer, nullable=False, default=1)
|
||||
|
||||
name = Column(String, nullable=False)
|
||||
|
||||
@@ -9,7 +9,7 @@ from .._model_base import BaseMixins, SqlAlchemyBase
|
||||
from .._model_utils import GUID, auto_init
|
||||
from ..group.invite_tokens import GroupInviteToken
|
||||
from ..group.webhooks import GroupWebhooksModel
|
||||
from ..recipe.category import Category, group2categories
|
||||
from ..recipe.category import Category, group_to_categories
|
||||
from ..server.task import ServerTaskModel
|
||||
from .cookbook import CookBook
|
||||
from .mealplan import GroupMealPlan
|
||||
@@ -21,7 +21,7 @@ class Group(SqlAlchemyBase, BaseMixins):
|
||||
id = sa.Column(GUID, primary_key=True, default=GUID.generate)
|
||||
name = sa.Column(sa.String, index=True, nullable=False, unique=True)
|
||||
users = orm.relationship("User", back_populates="group")
|
||||
categories = orm.relationship(Category, secondary=group2categories, single_parent=True, uselist=True)
|
||||
categories = orm.relationship(Category, secondary=group_to_categories, single_parent=True, uselist=True)
|
||||
|
||||
invite_tokens = orm.relationship(
|
||||
GroupInviteToken, back_populates="group", cascade="all, delete-orphan", uselist=True
|
||||
|
||||
@@ -9,6 +9,8 @@ from .._model_utils import auto_init
|
||||
|
||||
class GroupPreferencesModel(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "group_preferences"
|
||||
id = sa.Column(GUID, primary_key=True, default=GUID.generate)
|
||||
|
||||
group_id = sa.Column(GUID, sa.ForeignKey("groups.id"), nullable=False, index=True)
|
||||
group = orm.relationship("Group", back_populates="preferences")
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import Boolean, Column, ForeignKey, Integer, String, orm
|
||||
from sqlalchemy import Boolean, Column, ForeignKey, String, orm
|
||||
|
||||
from .._model_base import BaseMixins, SqlAlchemyBase
|
||||
from .._model_utils import GUID, auto_init
|
||||
@@ -6,7 +6,7 @@ from .._model_utils import GUID, auto_init
|
||||
|
||||
class GroupWebhooksModel(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "webhook_urls"
|
||||
id = Column(Integer, primary_key=True)
|
||||
id = Column(GUID, primary_key=True, default=GUID.generate)
|
||||
|
||||
group = orm.relationship("Group", back_populates="webhooks", single_parent=True)
|
||||
group_id = Column(GUID, ForeignKey("groups.id"), index=True)
|
||||
|
||||
@@ -11,8 +11,8 @@ from .._model_utils.guid import GUID
|
||||
logger = root_logger.get_logger()
|
||||
|
||||
|
||||
group2categories = sa.Table(
|
||||
"group2categories",
|
||||
group_to_categories = sa.Table(
|
||||
"group_to_categories",
|
||||
SqlAlchemyBase.metadata,
|
||||
sa.Column("group_id", GUID, sa.ForeignKey("groups.id")),
|
||||
sa.Column("category_id", GUID, sa.ForeignKey("categories.id")),
|
||||
@@ -35,7 +35,7 @@ recipes_to_categories = sa.Table(
|
||||
cookbooks_to_categories = sa.Table(
|
||||
"cookbooks_to_categories",
|
||||
SqlAlchemyBase.metadata,
|
||||
sa.Column("cookbook_id", sa.Integer, sa.ForeignKey("cookbooks.id")),
|
||||
sa.Column("cookbook_id", GUID, sa.ForeignKey("cookbooks.id")),
|
||||
sa.Column("category_id", GUID, sa.ForeignKey("categories.id")),
|
||||
)
|
||||
|
||||
|
||||
@@ -27,12 +27,12 @@ plan_rules_to_tags = sa.Table(
|
||||
class Tag(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "tags"
|
||||
__table_args__ = (sa.UniqueConstraint("slug", "group_id", name="tags_slug_group_id_key"),)
|
||||
id = sa.Column(guid.GUID, primary_key=True, default=guid.GUID.generate)
|
||||
|
||||
# ID Relationships
|
||||
group_id = sa.Column(guid.GUID, sa.ForeignKey("groups.id"), nullable=False, index=True)
|
||||
group = orm.relationship("Group", back_populates="tags", foreign_keys=[group_id])
|
||||
|
||||
id = sa.Column(guid.GUID, primary_key=True, default=guid.GUID.generate)
|
||||
name = sa.Column(sa.String, index=True, nullable=False)
|
||||
slug = sa.Column(sa.String, index=True, nullable=False)
|
||||
recipes = orm.relationship("RecipeModel", secondary=recipes_to_tags, back_populates="tags")
|
||||
|
||||
@@ -15,8 +15,8 @@ recipes_to_tools = Table(
|
||||
|
||||
class Tool(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "tools"
|
||||
id = Column(GUID, primary_key=True, default=GUID.generate)
|
||||
__table_args__ = (UniqueConstraint("slug", "group_id", name="tools_slug_group_id_key"),)
|
||||
id = Column(GUID, primary_key=True, default=GUID.generate)
|
||||
|
||||
# ID Relationships
|
||||
group_id = Column(GUID, ForeignKey("groups.id"), nullable=False)
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
from sqlalchemy import Boolean, Column, Integer, String
|
||||
|
||||
from mealie.db.models._model_base import BaseMixins, SqlAlchemyBase
|
||||
|
||||
from ._model_utils import auto_init
|
||||
|
||||
|
||||
class SignUp(SqlAlchemyBase, BaseMixins):
|
||||
__tablename__ = "sign_ups"
|
||||
id = Column(Integer, primary_key=True)
|
||||
token = Column(String, nullable=False, index=True)
|
||||
name = Column(String, index=True)
|
||||
admin = Column(Boolean, default=False)
|
||||
|
||||
@auto_init()
|
||||
def __init__(self, **_) -> None:
|
||||
pass
|
||||
Reference in New Issue
Block a user