forked from django/django
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #23699 -- Prevented flush from loading initial data for apps wi…
…th migrations.
- Loading branch information
Showing
8 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[ | ||
{ | ||
"pk": "10", | ||
"model": "fixtures_migration.book", | ||
"fields": { | ||
"name": "Achieving self-awareness of Python programs" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
"Book", | ||
[ | ||
("name", models.CharField(max_length=100)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.db import models | ||
|
||
|
||
class Book(models.Model): | ||
name = models.CharField(max_length=100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.test import TestCase | ||
from django.core import management | ||
|
||
from .models import Book | ||
|
||
|
||
class TestNoInitialDataLoading(TestCase): | ||
""" | ||
Apps with migrations should ignore initial data. This test can be removed | ||
in Django 1.9 when migrations become required and initial data is no longer | ||
supported. | ||
""" | ||
available_apps = ['fixtures_migration'] | ||
|
||
def test_migrate(self): | ||
self.assertQuerysetEqual(Book.objects.all(), []) | ||
management.call_command( | ||
'migrate', | ||
verbosity=0, | ||
) | ||
self.assertQuerysetEqual(Book.objects.all(), []) | ||
|
||
def test_flush(self): | ||
self.assertQuerysetEqual(Book.objects.all(), []) | ||
management.call_command( | ||
'flush', | ||
verbosity=0, | ||
interactive=False, | ||
load_initial_data=False | ||
) | ||
self.assertQuerysetEqual(Book.objects.all(), []) |