|
@@ -5,13 +5,6 @@ Upgrading
|
5
|
5
|
This document explains some of the issues that can be encountered whilst
|
6
|
6
|
upgrading Oscar.
|
7
|
7
|
|
8
|
|
-.. note::
|
9
|
|
-
|
10
|
|
- Detailed upgrade instructions for specific releases can be found on the `Github
|
11
|
|
- wiki`_.
|
12
|
|
-
|
13
|
|
-.. _`Github wiki`: https://github.com/tangentlabs/django-oscar/wiki/Upgrading
|
14
|
|
-
|
15
|
8
|
Migrations
|
16
|
9
|
----------
|
17
|
10
|
|
|
@@ -37,14 +30,44 @@ For instance, if you have ``oscar.apps.core.shipping`` in your
|
37
|
30
|
|
38
|
31
|
to migrate your shipping app.
|
39
|
32
|
|
40
|
|
-Migrating customised apps
|
41
|
|
-~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
33
|
+Migrating customised apps (models unchanged)
|
|
34
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
35
|
+
|
|
36
|
+If you have customised an app, but have not touched the models nor migrations,
|
|
37
|
+you're best off copying the migrations from Oscar. This approach has the
|
|
38
|
+advantage of pulling in any data migrations.
|
|
39
|
+Find the updated(!) Oscar in your virtualenv or clone the Oscar repo at the
|
|
40
|
+correct version tag. Then find the migrations, copy them across, and migrate as
|
|
41
|
+usual. You will have to adapt paths, but something akin to this will work::
|
42
|
42
|
|
43
|
|
-For apps that you are customising, you need to create a new migration that picks
|
44
|
|
-up the changes in the core Oscar models.
|
45
|
|
-For instance, if you have an app ``myproject.shipping`` that replaces
|
46
|
|
-``oscar.apps.shipping`` in your ``INSTALLED_APPS`` then you can simply run::
|
|
43
|
+ $ cdsitepackages oscar/apps/shipping/migrations
|
|
44
|
+ $ copy *.py <your_project>/myshop/shipping/migrations/
|
|
45
|
+
|
|
46
|
+Migrating customised apps (models changed)
|
|
47
|
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
48
|
+
|
|
49
|
+At this point, you have essentially forked away from Oscar's migrations. Read
|
|
50
|
+the release notes carefully and see if it includes data migrations. If not,
|
|
51
|
+it's as easy as::
|
47
|
52
|
|
48
|
53
|
./manage.py schemamigration shipping --auto
|
49
|
54
|
|
50
|
55
|
to create the appropriate migration.
|
|
56
|
+
|
|
57
|
+But if there is data migrations, you will need to look into what they do, and
|
|
58
|
+likely will have to imitate what they're doing. You can't just copy across the
|
|
59
|
+entire data migration (because the South's fake ORM snapshot will be wrong),
|
|
60
|
+but you can usually create a data migration like this::
|
|
61
|
+
|
|
62
|
+ ./manage.py datamigration shipping descriptive_name
|
|
63
|
+
|
|
64
|
+and then copy the code portion from Oscar's migration into your newly
|
|
65
|
+created migration.
|
|
66
|
+
|
|
67
|
+If there's also schema migrations, then you need to also create a schema
|
|
68
|
+migration::
|
|
69
|
+
|
|
70
|
+ ./manage.py schemamigration shipping --auto
|
|
71
|
+
|
|
72
|
+The fun part is figuring out if you have to create the schema migration before
|
|
73
|
+or after the data migration.
|