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.

create_migration.sh 1.6KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/env bash
  2. #
  3. # Rather verbose and destructive script to create both South migrations and the
  4. # new native migrations (which we need as we support both Django 1.6 and 1.7).
  5. # This will install and uninstall Django versions in your virtualenv, only work
  6. # with the default SQLite database, destroy that database repeatedly
  7. # Grab current version of Django from virtualenv
  8. DJANGO_VERSION=$(pip freeze | awk 'BEGIN {FS="=="} /Django/ {print $2}')
  9. SOUTH_VERSION=$(pip freeze | awk 'BEGIN {FS="=="} /South/ {print $2}')
  10. APPS=( analytics checkout address shipping catalogue reviews partner basket payment \
  11. offer order customer promotions search voucher wishlists )
  12. echo "Uninstalling Django(==$DJANGO_VERSION) and South(==$SOUTH_VERSION)"
  13. pip uninstall Django South -y
  14. echo "Generating Django-native (>=1.7) migrations"
  15. # Commit of the stable/1.7.x branch that contains fix for https://code.djangoproject.com/ticket/23041,
  16. # but doesn't suffer from https://code.djangoproject.com/ticket/23014
  17. pip install https://github.com/django/django/archive/88135a8cf7d587b88e47f1223cf01c7698b52b74.zip
  18. rm -f sites/sandbox/db.sqlite
  19. sites/sandbox/manage.py migrate
  20. sites/sandbox/manage.py makemigrations ${APPS[@]}
  21. echo "Generating Django 1.6 migrations"
  22. pip install "Django==1.6.5" "South==1.0"
  23. rm -f sites/sandbox/db.sqlite
  24. sites/sandbox/manage.py syncdb --noinput
  25. sites/sandbox/manage.py migrate
  26. for APP in "${APPS[@]}"
  27. do
  28. sites/sandbox/manage.py schemamigration $APP --auto
  29. done
  30. echo "Restoring Django(==$DJANGO_VERSION) and South(==$SOUTH_VERSION)"
  31. pip install "Django==$DJANGO_VERSION" "South==$SOUTH_VERSION"