1 | #!/bin/bash
|
---|
2 |
|
---|
3 | set -e
|
---|
4 |
|
---|
5 | # Clean up a previous invocation:
|
---|
6 | rm -rf mysite
|
---|
7 |
|
---|
8 | python3 -m venv venv
|
---|
9 | source venv/bin/activate
|
---|
10 |
|
---|
11 | # Use Django 4 to generate migrations for models.py files with index_together.
|
---|
12 | pip install -U 'django==4.2.24'
|
---|
13 |
|
---|
14 | django-admin startproject mysite
|
---|
15 | cd mysite
|
---|
16 |
|
---|
17 | python manage.py startapp polls
|
---|
18 | echo "INSTALLED_APPS.append('polls')" >> mysite/settings.py
|
---|
19 |
|
---|
20 | cp ../models_1.py polls/models.py
|
---|
21 | python manage.py makemigrations
|
---|
22 |
|
---|
23 | cp ../models_2.py polls/models.py
|
---|
24 | python manage.py makemigrations
|
---|
25 |
|
---|
26 | cp ../models_3.py polls/models.py
|
---|
27 | python manage.py makemigrations
|
---|
28 |
|
---|
29 | pip install django==5.2.6
|
---|
30 |
|
---|
31 | # `migrate` now fails on Django 5 with the following error:
|
---|
32 | # ValueError: Found wrong number (0) of indexes for polls_mymodel(a, b).
|
---|
33 | # It does not fail with Django 4. To see this, comment out the django==5 line
|
---|
34 | # above and re-run the script.
|
---|
35 | python manage.py migrate
|
---|