-
-
Notifications
You must be signed in to change notification settings - Fork 31.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #22749: Making SQL management commands migration aware.
- Loading branch information
1 parent
6fd455a
commit f70f669
Showing
7 changed files
with
72 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,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,), | ||
), | ||
] |
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,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) |
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
f70f669
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a technical reason why apps with migrations can't use the sql management command ? It can still be useful to get 'CREATE TABLE' statements for debugging models.
f70f669
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they won't be created with the same backend (unmigrated apps use Creation, migrated uses SchemaEditor) so the SQL won't match. The sqlmigrate command will do the same function for migrated apps (the sql command will be deprecated next release)
f70f669
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation Andrew :)