![Show Menu](styles/mobile-menu.png)
![Page Background](./../common/page-substrates/page0458.png)
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'lists'
,
'0004_item_list'
),
]
operations
=
[
migrations
.
RunPython
(
find_dupes
),
]
Re-creating the Old Migration
We re-create the old migration using
makemigrations
, which will ensure it is now the
sixth migration and has an explicit dependency on
0005
, the data migration:
$
python3 manage.py makemigrations
Migrations for 'lists':
0006_auto_20140415_0018.py:
- Alter unique_together for item (1 constraints)
$
mv lists/migrations/0006_* lists/migrations/0006_unique_together.py
Testing the New Migrations Together
We’re now ready to run our test against the live data:
$
cd deploy_tools
$
fab deploy
:host=elspeth@superlists-staging.ottg.eu[...]
We’ll need to restart the live Gunicorn job too:
elspeth@server:$
sudo restart gunicorn-superlists.ottg.eu
And we can now run our FTs against staging:
$
python3 manage.py test functional_tests --liveserver=superlists-staging.ottg.eu
Creating test database for alias 'default'...
....
---------------------------------------------------------------------
Ran 4 tests in 17.308s
OK
Everything seems in order! Let’s do it against live:
$
fab deploy --host=superlists.ottg.eu
[superlists.ottg.eu] Executing task 'deploy'
[...]
And that’s a wrap.
git add lists/migrations
,
git commit
, etc.
430
|
Appendix D: Testing Database Migrations