summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2014-06-01 12:00:09 +0200
committerFlorian Apolloner <florian@apolloner.eu>2014-06-01 12:00:09 +0200
commit83e7555ffee305c1ea1e0655fd1f0aa35269533f (patch)
treee32cdf9bdebdf04c4b5985b03434b4d4a691aaf8
parent875ce287e25d7576f9bd102f86adae09d242360f (diff)
Revert "Making SQL management commands migration aware."
This reverts commit cb9c9a7b5879671053c7d2ad6e79943a8814b274.
-rw-r--r--django/core/management/commands/sqlsequencereset.py2
-rw-r--r--django/core/management/sql.py24
-rw-r--r--tests/commands_sql_migrations/__init__.py0
-rw-r--r--tests/commands_sql_migrations/migrations/0001_initial.py33
-rw-r--r--tests/commands_sql_migrations/migrations/__init__.py0
-rw-r--r--tests/commands_sql_migrations/models.py10
6 files changed, 0 insertions, 69 deletions
diff --git a/django/core/management/commands/sqlsequencereset.py b/django/core/management/commands/sqlsequencereset.py
index 4f7ce4492a..9d25125efb 100644
--- a/django/core/management/commands/sqlsequencereset.py
+++ b/django/core/management/commands/sqlsequencereset.py
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
from optparse import make_option
from django.core.management.base import AppCommand
-from django.core.management.sql import check_for_migrations
from django.db import connections, DEFAULT_DB_ALIAS
@@ -23,7 +22,6 @@ class Command(AppCommand):
if app_config.models_module is None:
return
connection = connections[options.get('database')]
- check_for_migrations(app_config, connection)
models = app_config.get_models(include_auto_created=True)
statements = connection.ops.sequence_reset_sql(self.style, models)
return '\n'.join(statements)
diff --git a/django/core/management/sql.py b/django/core/management/sql.py
index 721afb2d04..437f8737c3 100644
--- a/django/core/management/sql.py
+++ b/django/core/management/sql.py
@@ -12,19 +12,9 @@ from django.db import models, router
from django.utils.deprecation import RemovedInDjango19Warning
-def check_for_migrations(app_config, connection):
- # Inner import to stop tests failing
- from django.db.migrations.loader import MigrationLoader
- loader = MigrationLoader(connection)
- if app_config.label in loader.migrated_apps:
- raise CommandError("App '%s' has migrations. Only the sqlmigrate and sqlflush commands can be used when an app has migrations." % app_config.label)
-
-
def sql_create(app_config, style, connection):
"Returns a list of the CREATE TABLE SQL statements for the given app."
- check_for_migrations(app_config, connection)
-
if connection.settings_dict['ENGINE'] == 'django.db.backends.dummy':
# This must be the "dummy" database backend, which means the user
# hasn't set ENGINE for the database.
@@ -71,8 +61,6 @@ def sql_create(app_config, style, connection):
def sql_delete(app_config, style, connection):
"Returns a list of the DROP TABLE SQL statements for the given app."
- check_for_migrations(app_config, connection)
-
# This should work even if a connection isn't available
try:
cursor = connection.cursor()
@@ -134,9 +122,6 @@ def sql_flush(style, connection, only_django=False, reset_sequences=True, allow_
def sql_custom(app_config, style, connection):
"Returns a list of the custom table modifying SQL statements for the given app."
-
- check_for_migrations(app_config, connection)
-
output = []
app_models = router.get_migratable_models(app_config, connection.alias)
@@ -149,9 +134,6 @@ def sql_custom(app_config, style, connection):
def sql_indexes(app_config, style, connection):
"Returns a list of the CREATE INDEX SQL statements for all models in the given app."
-
- check_for_migrations(app_config, connection)
-
output = []
for model in router.get_migratable_models(app_config, connection.alias, include_auto_created=True):
output.extend(connection.creation.sql_indexes_for_model(model, style))
@@ -160,9 +142,6 @@ def sql_indexes(app_config, style, connection):
def sql_destroy_indexes(app_config, style, connection):
"Returns a list of the DROP INDEX SQL statements for all models in the given app."
-
- check_for_migrations(app_config, connection)
-
output = []
for model in router.get_migratable_models(app_config, connection.alias, include_auto_created=True):
output.extend(connection.creation.sql_destroy_indexes_for_model(model, style))
@@ -170,9 +149,6 @@ def sql_destroy_indexes(app_config, style, connection):
def sql_all(app_config, style, connection):
-
- check_for_migrations(app_config, connection)
-
"Returns a list of CREATE TABLE SQL, initial-data inserts, and CREATE INDEX SQL for the given module."
return sql_create(app_config, style, connection) + sql_custom(app_config, style, connection) + sql_indexes(app_config, style, connection)
diff --git a/tests/commands_sql_migrations/__init__.py b/tests/commands_sql_migrations/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/commands_sql_migrations/__init__.py
+++ /dev/null
diff --git a/tests/commands_sql_migrations/migrations/0001_initial.py b/tests/commands_sql_migrations/migrations/0001_initial.py
deleted file mode 100644
index 39a53bf68f..0000000000
--- a/tests/commands_sql_migrations/migrations/0001_initial.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# -*- 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,),
- ),
- ]
diff --git a/tests/commands_sql_migrations/migrations/__init__.py b/tests/commands_sql_migrations/migrations/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
--- a/tests/commands_sql_migrations/migrations/__init__.py
+++ /dev/null
diff --git a/tests/commands_sql_migrations/models.py b/tests/commands_sql_migrations/models.py
deleted file mode 100644
index 78ad722307..0000000000
--- a/tests/commands_sql_migrations/models.py
+++ /dev/null
@@ -1,10 +0,0 @@
-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)