[Django] #21969: Dependent apps do not handle fixture data properly when migration

22 views
Skip to first unread message

Django

unread,
Feb 6, 2014, 6:30:34 PM2/6/14
to django-...@googlegroups.com
#21969: Dependent apps do not handle fixture data properly when migration
---------------------------------+--------------------
Reporter: Ubercore | Owner:
Type: Uncategorized | Status: new
Component: Migrations | Version: master
Severity: Release blocker | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------
I have {{{ app_a }}}, and {{{ app_b }}}. {{{ app_a }}} lists {{{ app_b }}}
as a dependency, and {{{ app_b }}} has a fixture in {{{ initial_data.json
}}}. When I run {{{ ./manage.py migrate }}}, the dependency is resolved
correctly, and {{{ app_b }}} is migrated first. However, it seems that the
fixture tries to load before the table exists:

{{{
$ ./manage.py migrate
Operations to perform:
Synchronize unmigrated apps: evolve, pipeline, mptt, sessions, admin,
suit_redactor, sites, auth, reversion, contenttypes, django_extensions,
taggit, suit, easy_thumbnails
Apply all migrations: content, translation, sites, auth
Synchronizing apps without migrations:
Creating tables...
Creating table django_admin_log
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_groups
Creating table auth_user_user_permissions
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table easy_thumbnails_source
Creating table easy_thumbnails_thumbnail
Creating table reversion_revision
Creating table reversion_version
Creating table taggit_tag
Creating table taggit_taggeditem
Installing custom SQL...
Installing indexes...
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/ENV/src/django/django/core/management/__init__.py",
line 427, in execute_from_command_line
utility.execute()
File "/home/vagrant/ENV/src/django/django/core/management/__init__.py",
line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/ENV/src/django/django/core/management/base.py", line
287, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/ENV/src/django/django/core/management/base.py", line
336, in execute
output = self.handle(*args, **options)
File
"/home/vagrant/ENV/src/django/django/core/management/commands/migrate.py",
line 125, in handle
created_models = self.sync_apps(connection,
executor.loader.unmigrated_apps)
File
"/home/vagrant/ENV/src/django/django/core/management/commands/migrate.py",
line 281, in sync_apps
call_command('loaddata', 'initial_data', verbosity=self.verbosity,
database=connection.alias, skip_validation=True)
File "/home/vagrant/ENV/src/django/django/core/management/__init__.py",
line 167, in call_command
return klass.execute(*args, **defaults)
File "/home/vagrant/ENV/src/django/django/core/management/base.py", line
336, in execute
output = self.handle(*args, **options)
File
"/home/vagrant/ENV/src/django/django/core/management/commands/loaddata.py",
line 56, in handle
self.loaddata(fixture_labels)
File
"/home/vagrant/ENV/src/django/django/core/management/commands/loaddata.py",
line 85, in loaddata
self.load_label(fixture_label)
File
"/home/vagrant/ENV/src/django/django/core/management/commands/loaddata.py",
line 140, in load_label
obj.save(using=self.using)
File "/home/vagrant/ENV/src/django/django/core/serializers/base.py",
line 172, in save
models.Model.save_base(self.object, using=using, raw=True)
File "/home/vagrant/ENV/src/django/django/db/models/base.py", line 630,
in save_base
updated = self._save_table(raw, cls, force_insert, force_update,
using, update_fields)
File "/home/vagrant/ENV/src/django/django/db/models/base.py", line 692,
in _save_table
forced_update)
File "/home/vagrant/ENV/src/django/django/db/models/base.py", line 736,
in _do_update
return filtered._update(values) > 0
File "/home/vagrant/ENV/src/django/django/db/models/query.py", line 595,
in _update
return query.get_compiler(self.db).execute_sql(CURSOR)
File "/home/vagrant/ENV/src/django/django/db/models/sql/compiler.py",
line 991, in execute_sql
cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
File "/home/vagrant/ENV/src/django/django/db/models/sql/compiler.py",
line 779, in execute_sql
cursor.execute(sql, params)
File "/home/vagrant/ENV/src/django/django/db/backends/utils.py", line
77, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/vagrant/ENV/src/django/django/db/backends/utils.py", line
61, in execute
return self.cursor.execute(sql, params)
File "/home/vagrant/ENV/src/django/django/db/utils.py", line 93, in
__exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/vagrant/ENV/src/django/django/db/backends/utils.py", line
61, in execute
return self.cursor.execute(sql, params)
File "/home/vagrant/ENV/src/django/django/db/backends/sqlite3/base.py",
line 494, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: Problem installing fixture
'/home/vagrant/seie/translation/fixtures/initial_data.json': Could not
load translation.Language(pk=1): no such table: translation_language
}}}

In the example above, app_a is content, and app_b is translation. Also
note that this example is run immediately after a {{{ reset_db }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21969>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 6, 2014, 6:35:01 PM2/6/14
to django-...@googlegroups.com
#21969: Dependent apps do not handle fixture data properly when migration
---------------------------------+--------------------------------------
Reporter: Ubercore | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Ubercore):

* needs_better_patch: => 0
* type: Uncategorized => Bug
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/21969#comment:1>

Django

unread,
Feb 7, 2014, 9:52:19 AM2/7/14
to django-...@googlegroups.com
#21969: Dependent apps do not handle fixture data properly when migration
---------------------------------+--------------------------------------
Reporter: Ubercore | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------
Changes (by Ubercore):

* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/21969#comment:2>

Django

unread,
Feb 8, 2014, 3:37:12 PM2/8/14
to django-...@googlegroups.com
#21969: Dependent apps do not handle fixture data properly when migration
---------------------------------+------------------------------------
Reporter: Ubercore | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by aaugustin):

* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/21969#comment:3>

Django

unread,
Feb 9, 2014, 6:54:13 AM2/9/14
to django-...@googlegroups.com
#21969: Dependent apps do not handle fixture data properly when migration
---------------------------------+------------------------------------
Reporter: Ubercore | Owner:
Type: Bug | Status: new
Component: Migrations | Version: master

Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------

Comment (by andrewgodwin):

This bug is actually that initial_data shouldn't be loaded at all for apps
with migrations, it's been deprecated (if you want to load initial data
it's now suggested to use the RunPython operation and do it using the
ORM).

I'll fix it so initial_data is only run for unmigrated apps.

--
Ticket URL: <https://code.djangoproject.com/ticket/21969#comment:4>

Django

unread,
Feb 9, 2014, 7:23:18 AM2/9/14
to django-...@googlegroups.com
#21969: Dependent apps do not handle fixture data properly when migration
-------------------------------------+-------------------------------------
Reporter: Ubercore | Owner: Andrew
Type: Bug | Godwin <andrew@…>
Component: Migrations | Status: closed
Severity: Release blocker | Version: master
Keywords: | Resolution: fixed
Has patch: 0 | Triage Stage: Accepted
Needs tests: 1 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Andrew Godwin <andrew@…>):

* status: new => closed
* owner: => Andrew Godwin <andrew@…>
* resolution: => fixed


Comment:

In [changeset:"d5df7a0515b08621a526a9c9ffde7d7702c5b07e"]:
{{{
#!CommitTicketReference repository=""
revision="d5df7a0515b08621a526a9c9ffde7d7702c5b07e"
Fixed #21969: Fix behaviour of initial_data with migrated apps
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21969#comment:5>

Reply all
Reply to author
Forward
0 new messages