返回提示词目录第 1162 页

分阶段升级框架并验证兼容性

为现有项目规划逐版升级路径,处理依赖、弃用接口与配置变化,并汇总测试和迁移检查结果。

完整提示词

<context>
Django's deprecation policy makes upgrades predictable if you use it: a feature is deprecated with a warning and removed two feature releases later, so code that runs warning-free on one release will usually run on the next. Django's own advice is to step through each feature release rather than jump between LTS versions, fixing deprecation warnings at each step. What experienced people check: Python version support for each Django release (newer Django drops older Pythons, and some steps require a Python upgrade first); minimum versions of the database server and driver; third-party packages, which are the usual blockers; settings defaults that changed (for example time zone support on by default in 5.0, the auto primary key field type, CSRF trusted origins needing a scheme in 4.0); removed APIs (`url()`, `ugettext`, `pytz` integration, `index_together`); and new migrations generated by model option changes, which `makemigrations --check` reveals. Running tests with warnings enabled (`python -Wa manage.py test`, or pytest's warning filters set to error for Django deprecations) is the fastest way to find what will break. Automated rewriting tools exist for many deprecations and are worth running before hand-fixing.
</context>

<task>
Upgrade this Django project to {{target_version}}.
{{#notes}}
Notes:
{{notes}}
{{/notes}}

1. Read requirements or `pyproject.toml`, the lockfile, settings modules, the Python version in development, CI and production images, and the database version.
2. Build the upgrade path through each feature release from current to target, noting the Python and database minimums of each and where a Python upgrade must come first.
3. Check each third-party package for a version supporting each step. Stop for a decision on any package with no supported version.
4. Record the baseline: tests with deprecation warnings shown, `makemigrations --check`, and `check --deploy`.
5. For each step: fix deprecation warnings on the current version first, then bump Django and packages, read that release's notes for backwards-incompatible changes that apply, fix failures, run `makemigrations --check` and review any generated migration, and commit.
6. Review changed setting defaults at each step and set them explicitly where the old behaviour must stay.
7. After the final step, run the full test suite with warnings as errors for Django deprecations, `check --deploy`, and a staging run of migrations against a copy of production-sized data if the user can provide one.
</task>

<constraints>
- Fix deprecation warnings before bumping; do not suppress them.
- Never run migrations against a production database as part of this work.
- Do not accept auto-generated migrations without reading them; some change behaviour or lock large tables.
- Do not guess release notes or version minimums; read them from the official release notes.

{{> guardrails/verify-before-done}}
{{> guardrails/scope-discipline}}
</constraints>

<output_format>
## Starting point
Django, Python, database and package versions; baseline warnings.
## Upgrade path
Table: step, Django version, Python and database minimums, notable changes.
## Package compatibility
Table: package, version per step, blockers.
## Changes per step
Warnings fixed, incompatible changes handled, settings made explicit, migrations generated.
## Verification
Tests, checks and migration runs, with results.
</output_format>

可替换内容

  • {{target_version}}
  • {{#notes}}
  • {{notes}}
  • {{/notes}}
  • {{> guardrails/verify-before-done}}
  • {{> guardrails/scope-discipline}}

分类与标签

编程开发、框架升级、依赖兼容、弃用接口、数据库迁移

前往 AI 图片创作