1 | # Demonstrate an issue with the new Django migrations
|
---|
2 | # and the unique_together setting with foriegn keys.
|
---|
3 |
|
---|
4 | # Requires that the tip of Django is already installed.
|
---|
5 |
|
---|
6 | # Die on error
|
---|
7 | set -e
|
---|
8 |
|
---|
9 | # Create a new project called 'spam'
|
---|
10 | django-admin startproject spam
|
---|
11 |
|
---|
12 | # Go into the new project
|
---|
13 | cd spam
|
---|
14 |
|
---|
15 | # Create a new app called 'eggs'
|
---|
16 | django-admin startapp eggs
|
---|
17 |
|
---|
18 | # Add the new app to settings.py
|
---|
19 | cat >> spam/settings.py <<EOF
|
---|
20 | INSTALLED_APPS = 'eggs',
|
---|
21 | EOF
|
---|
22 |
|
---|
23 | # Create the basic failing models
|
---|
24 | cat > eggs/models.py <<EOF
|
---|
25 | from django.db import models
|
---|
26 |
|
---|
27 | class Knight(models.Model):
|
---|
28 | pass
|
---|
29 |
|
---|
30 | class Rabbit(models.Model):
|
---|
31 | class Meta:
|
---|
32 | unique_together = (('knight', 'parent'),)
|
---|
33 | knight = models.ForeignKey(Knight)
|
---|
34 | parent = models.ForeignKey('self', related_name='children')
|
---|
35 | EOF
|
---|
36 |
|
---|
37 | # Create the migrations
|
---|
38 | python manage.py makemigrations
|
---|
39 |
|
---|
40 | # Apply the migrations
|
---|
41 | python manage.py migrate --no-initial-data
|
---|