🗑️ Remove flat_label artifact
This commit is contained in:
parent
2399b28c52
commit
4550549c2c
1 changed files with 4 additions and 12 deletions
|
|
@ -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),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue