You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upgrading.rst 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. ---------
  2. Upgrading
  3. ---------
  4. This document explains some of the issues that can be encountered whilst
  5. upgrading Oscar.
  6. Migrations
  7. ----------
  8. Oscar provides migrations for its apps. But since Oscar allows
  9. an app to be overridden and its models extended, handling migrations can be
  10. tricky when upgrading.
  11. Suppose a new version of Oscar changes the models of the 'shipping' app and
  12. includes the corresponding migrations. There are two scenarios to be aware of:
  13. Migrating apps
  14. ~~~~~~~~~~~~~~
  15. Apps that you aren't customising will upgrade trivially as your project
  16. will pick up the new migrations from Oscar directly.
  17. For instance, if you have ``oscar.apps.core.shipping`` in your
  18. ``INSTALLED_APPS`` then you can simply run::
  19. ./manage.py makemigrations shipping
  20. to migrate your shipping app.
  21. Migrating customised apps (models unchanged)
  22. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  23. If you have customised an app, but have not touched the models nor migrations,
  24. you're best off copying the migrations from Oscar. This approach has the
  25. advantage of pulling in any data migrations.
  26. Find the updated(!) Oscar in your virtualenv or clone the Oscar repository at the
  27. correct version tag. Then find the migrations, copy them across, and migrate as
  28. usual. You will have to adapt paths, but something akin to this will work::
  29. $ cdsitepackages oscar/apps/shipping/migrations
  30. $ copy *.py <your_project>/myshop/shipping/migrations/
  31. .. _migrate_customised_apps_with_model_changes:
  32. Migrating customised apps (models changed)
  33. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. At this point, you have essentially forked away from Oscar's migrations. You will
  35. need to review all migrations that the Oscar release ships. Please also carefully
  36. read the release notes; tricky migrations will usually be mentioned.
  37. If there are data migrations, you will need to look into what they do, and
  38. likely will have to imitate what they're doing. You can copy across the
  39. `RunPython` part of data migration, but you have to mind the migration dependencies
  40. to ensure your data migration is executed in the right order.
  41. For schema migrations, it can sometimes be as easy as::
  42. ./manage.py makemigrations shipping
  43. to mirror the changes Oscar did.
  44. But other times, you will get dependency errors because new Oscar migrations
  45. reference a migration you don't have. One can get around this by creating
  46. an empty migration with the same name. See `this thread`_ on the mailing list.
  47. Feel free to get in touch on the mailing list if you run into any problems.
  48. .. _`this thread`: https://groups.google.com/g/django-oscar/c/2GL2XGHRcwM