mirror of
https://github.com/primedigitaltech/market-assistant.git
synced 2026-07-22 08:01:34 +08:00
chore(django): fail fast with hint when pipeline 0012/0013 migration files missing
Made-with: Cursor
This commit is contained in:
parent
34fe9079ee
commit
a1b02e3ed7
@ -2,11 +2,34 @@
|
|||||||
"""Django's command-line utility for administrative tasks."""
|
"""Django's command-line utility for administrative tasks."""
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def _require_pipeline_migration_files() -> None:
|
||||||
|
"""0013 依赖 0012;缺文件时 MigrationLoader 报 NodeNotFoundError,此处给出可操作的提示。"""
|
||||||
|
base = Path(__file__).resolve().parent
|
||||||
|
required = (
|
||||||
|
base / "pipeline" / "migrations" / "0012_job_pause_checkpoint.py",
|
||||||
|
base / "pipeline" / "migrations" / "0013_rebuild_pipelinejobcheckpoint.py",
|
||||||
|
)
|
||||||
|
missing = [p for p in required if not p.is_file()]
|
||||||
|
if not missing:
|
||||||
|
return
|
||||||
|
print(
|
||||||
|
"Missing pipeline migration file(s) (clone/pull 不完整或误删):\n"
|
||||||
|
+ "\n".join(f" - {p}" for p in missing)
|
||||||
|
+ "\n\nRestore from Git, e.g.\n"
|
||||||
|
" git checkout HEAD -- pipeline/migrations/0012_job_pause_checkpoint.py "
|
||||||
|
"pipeline/migrations/0013_rebuild_pipelinejobcheckpoint.py\n",
|
||||||
|
file=sys.stderr,
|
||||||
|
)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Run administrative tasks."""
|
"""Run administrative tasks."""
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'config.settings')
|
||||||
|
_require_pipeline_migration_files()
|
||||||
try:
|
try:
|
||||||
from django.core.management import execute_from_command_line
|
from django.core.management import execute_from_command_line
|
||||||
except ImportError as exc:
|
except ImportError as exc:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user