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.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. Read
  35. the release notes carefully and see if it includes data migrations. If not,
  36. it's as easy as::
  37. ./manage.py makemigrations shipping
  38. to create the appropriate migration.
  39. But if there is data migrations, you will need to look into what they do, and
  40. likely will have to imitate what they're doing. You can copy across the
  41. data migration, but you have to manually update the dependencies.
  42. If there's no schema migrations, you should set the data migration to depend
  43. on your last migration for that app. If there is a schema migration, you
  44. will have to imitate the dependency order of Oscar.
  45. Feel free to get in touch on the mailing list if you run into any problems.