#23635: Django 1.7 migration fails when adding order_with_respect_to on SQLite
server
-----------------------------------+--------------------------------------
Reporter: petkostas | Owner: nobody
Type: Uncategorized | Status: new
Component: Migrations | Version: 1.7
Severity: Normal | Resolution:
Keywords: sqlite, migration | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Description changed by petkostas:
Old description:
> Django 1.7 migration fails when adding Class Meta option
> "order_with_respect_to":
>
> Model (irrelevant fields have been omitted):
>
> {{{
> class ImageModel(LensCoreModel):
>
> categories = TreeManyToManyField('galleries.GalleryModel',
> related_name='images')
> ...
>
> class Meta:
> order_with_respect_to = 'categories'
> }}}
>
> Creating the migration:
>
> {{{
> (lensframe)vagrant@vagrant-ubuntu-
> trusty-64:/data/python/lensframe/lensframe$ python manage.py
> makemigrations galleries
> Migrations for 'galleries':
> 0007_auto_20141010_1305.py:
> - Change Meta options on imagemodel
> - Set order_with_respect_to on imagemodel to categories
> }}}
>
> Running migration:
>
> {{{
> (lensframe)vagrant@vagrant-ubuntu-
> trusty-64:/data/python/lensframe/lensframe$ python manage.py migrate
> galleries
> Operations to perform:
> Apply all migrations: galleries
> Running migrations:
> Applying galleries.0007_auto_20141010_1305...Traceback (most recent
> call last):
> File "manage.py", line 10, in <module>
> execute_from_command_line(sys.argv)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/core/management/__init__.py", line 385, in
> execute_from_command_line
> utility.execute()
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/core/management/__init__.py", line 377, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/core/management/base.py", line 288, in run_from_argv
> self.execute(*args, **options.__dict__)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/core/management/base.py", line 338, in execute
> output = self.handle(*args, **options)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/core/management/commands/migrate.py", line 160, in handle
> executor.migrate(targets, plan, fake=options.get("fake", False))
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/migrations/executor.py", line 63, in migrate
> self.apply_migration(migration, fake=fake)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/migrations/executor.py", line 97, in apply_migration
> migration.apply(project_state, schema_editor)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/migrations/migration.py", line 107, in apply
> operation.database_forwards(self.app_label, schema_editor,
> project_state, new_state)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/migrations/operations/models.py", line 332, in
> database_forwards
> field,
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/sqlite3/schema.py", line 160, in add_field
> self._remake_table(model, create_fields=[field])
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/sqlite3/schema.py", line 128, in
> _remake_table
> self.quote_name(model._meta.db_table),
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/schema.py", line 98, in execute
> cursor.execute(sql, params)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/utils.py", line 81, in execute
> return super(CursorDebugWrapper, self).execute(sql, params)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/utils.py", line 65, in execute
> return self.cursor.execute(sql, params)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/utils.py", line 94, in __exit__
> six.reraise(dj_exc_type, dj_exc_value, traceback)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/utils.py", line 65, in execute
> return self.cursor.execute(sql, params)
> File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
> packages/django/db/backends/sqlite3/base.py", line 485, in execute
> return Database.Cursor.execute(self, query, params)
> django.db.utils.IntegrityError: NOT NULL constraint failed:
> galleries_imagemodel__new._order
>
> }}}
>
> I know this issue is sqlite related, but I believe we need a workaround
> as production is based on MySQL and testing on sqlite.
New description:
Django 1.7 migration fails when adding Class Meta option
"order_with_respect_to":
Model (irrelevant fields have been omitted):
{{{
class ImageModel(LensCoreModel):
categories = TreeManyToManyField('galleries.GalleryModel',
related_name='images')
...
class Meta:
order_with_respect_to = 'categories'
}}}
Creating the migration:
{{{
(lensframe)vagrant@vagrant-ubuntu-
trusty-64:/data/python/lensframe/lensframe$ python manage.py
makemigrations galleries
Migrations for 'galleries':
0007_auto_20141010_1305.py:
- Change Meta options on imagemodel
- Set order_with_respect_to on imagemodel to categories
}}}
Running migration:
{{{
(lensframe)vagrant@vagrant-ubuntu-
trusty-64:/data/python/lensframe/lensframe$ python manage.py migrate
galleries
Operations to perform:
Apply all migrations: galleries
Running migrations:
Applying galleries.0007_auto_20141010_1305...Traceback (most recent call
last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/core/management/commands/migrate.py", line 160, in handle
executor.migrate(targets, plan, fake=options.get("fake", False))
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/migrations/executor.py", line 63, in migrate
self.apply_migration(migration, fake=fake)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/migrations/executor.py", line 97, in apply_migration
migration.apply(project_state, schema_editor)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/migrations/migration.py", line 107, in apply
operation.database_forwards(self.app_label, schema_editor,
project_state, new_state)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/migrations/operations/models.py", line 332, in
database_forwards
field,
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/sqlite3/schema.py", line 160, in add_field
self._remake_table(model, create_fields=[field])
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/sqlite3/schema.py", line 128, in _remake_table
self.quote_name(model._meta.db_table),
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/schema.py", line 98, in execute
cursor.execute(sql, params)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 81, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/utils.py", line 65, in execute
return self.cursor.execute(sql, params)
File "/home/vagrant/.virtualenvs/lensframe/local/lib/python2.7/site-
packages/django/db/backends/sqlite3/base.py", line 485, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: NOT NULL constraint failed:
galleries_imagemodel__new._order
}}}
--
--
Ticket URL: <https://code.djangoproject.com/ticket/23635#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.ba0ba9bc2f0537e3abbda1d20e9f1492%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.