Skip to content

Commit ef24b18

Browse files
committed
Produce erroring migration test
1 parent 5f7d4a3 commit ef24b18

File tree

6 files changed

+82
-1
lines changed

6 files changed

+82
-1
lines changed

runtests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
'simple_history',
2222
'simple_history.tests',
2323
'simple_history.tests.external',
24+
'simple_history.tests.migration_test_app',
2425
]
2526

2627
DEFAULT_SETTINGS = dict(

simple_history/tests/migration_test_app/__init__.py

Whitespace-only changes.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
import simple_history.models
6+
from django.conf import settings
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='DoYouKnow',
18+
fields=[
19+
('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)),
20+
],
21+
options={
22+
},
23+
bases=(models.Model,),
24+
),
25+
migrations.CreateModel(
26+
name='HistoricalYar',
27+
fields=[
28+
('id', models.IntegerField(verbose_name='ID', auto_created=True, db_index=True, blank=True)),
29+
('history_id', models.AutoField(serialize=False, primary_key=True)),
30+
('history_date', models.DateTimeField()),
31+
('history_type', models.CharField(choices=[('+', 'Created'), ('~', 'Changed'), ('-', 'Deleted')], max_length=1)),
32+
('history_user', models.ForeignKey(null=True, to=settings.AUTH_USER_MODEL)),
33+
],
34+
options={
35+
'verbose_name': 'historical yar',
36+
'ordering': ('-history_date', '-history_id'),
37+
},
38+
bases=(models.Model,),
39+
),
40+
migrations.CreateModel(
41+
name='WhatIMean',
42+
fields=[
43+
('doyouknow_ptr', models.OneToOneField(primary_key=True, to='migration_test_app.DoYouKnow', auto_created=True, parent_link=True, serialize=False)),
44+
],
45+
options={
46+
},
47+
bases=('migration_test_app.doyouknow',),
48+
),
49+
migrations.CreateModel(
50+
name='Yar',
51+
fields=[
52+
('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)),
53+
('what', models.ForeignKey(to='migration_test_app.WhatIMean')),
54+
],
55+
options={
56+
},
57+
bases=(models.Model,),
58+
),
59+
migrations.AddField(
60+
model_name='historicalyar',
61+
name='what_id',
62+
field=simple_history.models.CustomForeignKeyField(to='migration_test_app.WhatIMean', blank=True, null=True, related_name='+'),
63+
preserve_default=True,
64+
),
65+
]

simple_history/tests/migration_test_app/migrations/__init__.py

Whitespace-only changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from django.db import models
2+
from simple_history.models import HistoricalRecords
3+
4+
5+
class DoYouKnow(models.Model):
6+
pass
7+
8+
9+
class WhatIMean(DoYouKnow):
10+
pass
11+
12+
13+
class Yar(models.Model):
14+
what = models.ForeignKey(WhatIMean)
15+
history = HistoricalRecords()

simple_history/tests/tests/test_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ class TestMigrate(TestCase):
112112

113113
@skipUnless(django.get_version() >= "1.7", "Requires 1.7 migrations")
114114
def test_migrate_command(self):
115-
management.call_command('migrate', fake=True, stdout=StringIO())
115+
management.call_command('migrate', 'migration_test_app', fake=True, stdout=StringIO())

0 commit comments

Comments
 (0)