Browse Source

Improve docs on how to handle migrations when upgrading

As it came up on the mailing list again, I've clarified a few more
scenarios of what needs to be done with migrations when upgrading.
master
Maik Hoepfel 11 years ago
parent
commit
c678d747be
3 changed files with 49 additions and 13 deletions
  1. 5
    0
      docs/source/releases/v0.7.rst
  2. 8
    0
      docs/source/releases/v0.8.rst
  3. 36
    13
      docs/source/topics/upgrading.rst

+ 5
- 0
docs/source/releases/v0.7.rst View File

@@ -318,6 +318,11 @@ Migrations
318 318
     affected ``None``'s to ``''`` yourself; see the data migrations for our
319 319
     approach.
320 320
 
321
+.. note::
322
+
323
+    Be sure to read the detailed instructions for
324
+    :doc:`handling migrations </topics/upgrading>`.
325
+
321 326
 * Address:
322 327
 
323 328
     - ``0008`` - Forgotten migration for ``UserAddress.phone_number``

+ 8
- 0
docs/source/releases/v0.8.rst View File

@@ -161,10 +161,12 @@ Cleanup around shipping methods
161 161
 
162 162
 * ``WeightBand.upper_limit`` is now a ``DecimalField``, just like the other
163 163
   weight-related fields.
164
+
164 165
     - Stand-alone product: Products that "stand by themselves", neither have
165 166
       parent nor children.
166 167
     - Parent product: An overarching product, previously known as group product.
167 168
     - Child products: Products related to a common parent product
169
+
168 170
 .. _minor_changes_in_0.8:
169 171
 
170 172
 Minor changes
@@ -220,6 +222,7 @@ unavoidable:
220 222
   to ``children``.
221 223
 
222 224
 The following methods and properties have been deprecated:
225
+
223 226
 * ``Product.is_parent`` - Use ``is_group`` instead.
224 227
 * ``Product.is_variant`` - Use ``is_child`` instead.
225 228
 * ``Product.is_top_level`` - Test for ``is_standalone`` and/or ``is_parent`` instead.
@@ -443,6 +446,11 @@ Migrations
443 446
     Please double-check it's outcome and make sure to do something similar
444 447
     if you have forked the catalogue app.
445 448
 
449
+.. note::
450
+
451
+    Be sure to read the detailed instructions for
452
+    :doc:`handling migrations </topics/upgrading>`.
453
+
446 454
 * Address:
447 455
 
448 456
     - ``0011`` - ``AbstractAddress.search_text`` turned into a ``TextField``.

+ 36
- 13
docs/source/topics/upgrading.rst View File

@@ -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.

Loading…
Cancel
Save