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

1234567891011121314151617181920212223242526272829303132333435
  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. pip install Django==1.7.1
  16. rm -f sites/sandbox/db.sqlite
  17. sites/sandbox/manage.py migrate
  18. sites/sandbox/manage.py makemigrations ${APPS[@]}
  19. echo "Generating Django 1.6 migrations"
  20. pip install "Django==1.6.8" "South==1.0"
  21. rm -f sites/sandbox/db.sqlite
  22. sites/sandbox/manage.py syncdb --noinput
  23. sites/sandbox/manage.py migrate
  24. for APP in "${APPS[@]}"
  25. do
  26. sites/sandbox/manage.py schemamigration $APP --auto
  27. done
  28. echo "Restoring Django(==$DJANGO_VERSION) and South(==$SOUTH_VERSION)"
  29. pip install "Django==$DJANGO_VERSION" "South==$SOUTH_VERSION"