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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 uses South_ to provide 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. .. _South: http://south.readthedocs.org/en/latest/installation.html
  12. Suppose a new version of Oscar changes the models of the 'shipping' app and
  13. includes the corresponding migrations. There are two scenarios to be aware of:
  14. Migrating uncustomised apps
  15. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  16. Apps that you aren't customising will upgrade trivially as your project
  17. will pick up the new migrations from Oscar directly.
  18. For instance, if you have ``oscar.apps.core.shipping`` in your
  19. ``INSTALLED_APPS`` then you can simply run::
  20. ./manage.py migrate shipping
  21. to migrate your shipping app.
  22. Migrating customised apps (models unchanged)
  23. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. If you have customised an app, but have not touched the models nor migrations,
  25. you're best off copying the migrations from Oscar. This approach has the
  26. advantage of pulling in any data migrations.
  27. Find the updated(!) Oscar in your virtualenv or clone the Oscar repo at the
  28. correct version tag. Then find the migrations, copy them across, and migrate as
  29. usual. You will have to adapt paths, but something akin to this will work::
  30. $ cdsitepackages oscar/apps/shipping/migrations
  31. $ copy *.py <your_project>/myshop/shipping/migrations/
  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 schemamigration shipping --auto
  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't just copy across the
  41. entire data migration (because the South's fake ORM snapshot will be wrong),
  42. but you can usually create a data migration like this::
  43. ./manage.py datamigration shipping descriptive_name
  44. and then copy the code portion from Oscar's migration into your newly
  45. created migration.
  46. If there's also schema migrations, then you need to also create a schema
  47. migration::
  48. ./manage.py schemamigration shipping --auto
  49. The fun part is figuring out if you have to create the schema migration before
  50. or after the data migration.