🐛 Revoke support for table_name prefixes
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.
This commit is contained in:
parent
856ea12f52
commit
bcdd23652f
1 changed files with 0 additions and 19 deletions
|
|
@ -34,25 +34,6 @@ class ModelMeta(type(TortoiseModel)):
|
||||||
# Grab the Schema class for further processing.
|
# Grab the Schema class for further processing.
|
||||||
schema_opts = attrs.get("Schema", None)
|
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.
|
# Let Tortoise's Metaclass do it's thing.
|
||||||
new_cls = super().__new__(mcls, name, bases, attrs)
|
new_cls = super().__new__(mcls, name, bases, attrs)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue