🗑️ Remove flat_label artifact

This commit is contained in:
Brian Wiborg 2025-09-29 19:54:45 +02:00
parent 2399b28c52
commit 4550549c2c
No known key found for this signature in database

View file

@ -119,26 +119,18 @@ class Project:
def build_aerich_command(
self, app_label: str, db_url: Optional[str] = None
) -> AerichCommand:
# Resolve label to flat_label
if app_label in self._apps:
flat_label = app_label
else:
candidate = app_label.replace(".", "_")
if candidate in self._apps:
flat_label = candidate
else:
if app_label not in self._apps:
raise RuntimeError(f"App '{app_label}' is not registered")
# Get a fresh copy of the config (without aerich.models anywhere)
tortoise_cfg = copy.deepcopy(self.build_tortoise_config(db_url=db_url))
# Append aerich.models to the models list of the target app only
if flat_label in tortoise_cfg["apps"]:
tortoise_cfg["apps"][flat_label]["models"].append("aerich.models")
tortoise_cfg["apps"][app_label]["models"].append("aerich.models")
return AerichCommand(
tortoise_config=tortoise_cfg,
app=flat_label,
app=app_label,
location=str(self.migrations_dir),
)