From 3e15aa772296ba3fdd0c9b5f0223e5f127b63f5a Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Fri, 10 Oct 2025 15:48:40 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Support=20apps=20without=20any?= =?UTF-8?q?=20models?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ohmyapi/core/runtime.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/ohmyapi/core/runtime.py b/src/ohmyapi/core/runtime.py index 576e275..e3d700e 100644 --- a/src/ohmyapi/core/runtime.py +++ b/src/ohmyapi/core/runtime.py @@ -154,7 +154,10 @@ class Project: tortoise_cfg = self.build_tortoise_config(db_url=db_url) # Prevent leaking other app's models to Aerich. - tortoise_cfg["apps"] = {app_label: tortoise_cfg["apps"][app_label]} + if app_label in tortoise_cfg["apps"].keys(): + tortoise_cfg["apps"] = {app_label: tortoise_cfg["apps"][app_label]} + else: + tortoise_cfg["apps"] = {app_label: {"default_connection": "default", "models": []}} # Append aerich.models to the models list of the target app only tortoise_cfg["apps"][app_label]["models"].append("aerich.models") @@ -403,7 +406,7 @@ class App: """ return { "models": [ - f"{self.name}.{m.__name__}" for m in self.models[f"{self.name}.models"] + f"{self.name}.{m.__name__}" for m in self._models[f"{self.name}.models"] ], "middlewares": self.__serialize_middleware(), "routes": self.__serialize_router(),