1
0
mirror of https://github.com/django/django.git synced 2025-10-24 14:16:09 +00:00

Fixed #22749: Making SQL management commands migration aware.

This commit is contained in:
Víðir Valberg Guðmundsson
2014-05-29 23:03:10 +02:00
committed by Andrew Godwin
parent 6fd455adfc
commit f70f669941
7 changed files with 72 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Book',
fields=[
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
('title', models.CharField(db_index=True, max_length=100)),
('comments', models.ManyToManyField(to='commands_sql_migrations.Comment')),
],
options={
},
bases=(models.Model,),
),
]

View File

@@ -0,0 +1,10 @@
from django.db import models
class Comment(models.Model):
pass
class Book(models.Model):
title = models.CharField(max_length=100, db_index=True)
comments = models.ManyToManyField(Comment)

View File

@@ -20,7 +20,7 @@ class SQLCommandsMigrationsTestCase(TestCase):
def test_sql_delete(self):
app_config = apps.get_app_config('commands_sql_migrations')
with self.assertRaises(CommandError):
sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS])
sql_delete(app_config, no_style(), connections[DEFAULT_DB_ALIAS], close_connection=False)
def test_sql_indexes(self):
app_config = apps.get_app_config('commands_sql_migrations')