From bcdd23652f0e8ebcb19444bd92c5e0ac8dbde931 Mon Sep 17 00:00:00 2001 From: Brian Wiborg Date: Thu, 2 Oct 2025 15:09:02 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Revoke=20support=20for=20table?= =?UTF-8?q?=5Fname=20prefixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Unfortunately, Aerich seems a bit awkward in respecting Model.Meta.table. Also proxy-tables can not be prefixed at all. If there is no concise way to prefix all tables of an app, we shouldn't prefix it at all and leave the collision-problem for the user to keep an eye on. --- src/ohmyapi/db/model/model.py | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/src/ohmyapi/db/model/model.py b/src/ohmyapi/db/model/model.py index 2047f80..929ff60 100644 --- a/src/ohmyapi/db/model/model.py +++ b/src/ohmyapi/db/model/model.py @@ -34,25 +34,6 @@ class ModelMeta(type(TortoiseModel)): # Grab the Schema class for further processing. schema_opts = attrs.get("Schema", None) - # Create or get the inner Meta class - meta = attrs.get("Meta", type("Meta", (), {})) - - # Infer app name from module if not explicitly set - if not hasattr(meta, "app"): - module = attrs.get("__module__", "") - module_parts = module.split(".") - if module_parts[-1] == "models": - inferred_app = module_parts[-2] - else: - inferred_app = module_parts[-1] - # Rewrite builtin apps to ohmyapi_* alias - inferred_app = inferred_app.replace("ohmyapi.builtin.", "ohmyapi_") - meta.app = inferred_app - - # Prefix table name if not explicitly set - if not hasattr(meta, "table"): - meta.table = f"{meta.app}_{name.lower()}" - # Let Tortoise's Metaclass do it's thing. new_cls = super().__new__(mcls, name, bases, attrs)