migrate fails when installing zinnia for the first time on a production database
skozan opened this issue · 1 comments
Actual behavior
Installing zinnia to a production system, fails on zinnia.0003_publication_date
migration with some timeout.
It looks that fill_publication_date()
function in "/zinnia/migrations/0003_publication_date.py" timeouts when trying to access entries with: for entry in entry_klass.objects.all()
, but zinnia database is empty.
Exception follows:
(env) user@host:~/project_root$ ./manage.py migrate zinnia
Operations to perform:
Apply all migrations: zinnia
Running migrations:
Applying zinnia.0002_lead_paragraph_and_image_caption... OK
Applying zinnia.0003_publication_date...Traceback (most recent call last):
File "./manage.py", line 28, in <module>
execute_from_command_line(sys.argv)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/zinnia/migrations/0003_publication_date.py", line 7, in fill_publication_date
for entry in entry_klass.objects.all():
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 250, in __iter__
self._fetch_all()
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 1118, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/models/query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "/home/user/project_root/env/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
django.db.utils.OperationalError: canceling statement due to statement timeout
Expected behavior
Migrations, especially for a fresh zinnia installation without entries in database, should not raise time out exceptions, breaking also a deployment.
Workaround
Edited "0003_publication_date.py" file and added a return
in fill_publication_date()
so function body does not execute. Note that this may be ok only for a fresh - empty zinnia database.
Steps to reproduce the issue
- Add
zinnia
to settings.INSTALLED_APPS - python manage.py migrate (or python manage.py migrate zinnia, same output).
Specifications
- Database: PostgreSQL 9.6.8
- Zinnia version: 0.19
- Django version: 1.11.9
- Python version: 2.7.12
- Operating system: Ubuntu 16.04
Disclaimer
Before submitting an issue make sure you have:
- Read the guidelines for contributing.
- Checked for duplicate issues.
- Not a support request.
Hello,
I'm sorry but I cannot reproduce the issue.
On travis all I can see is that everything works on PG 9.6.6:
https://travis-ci.org/Fantomas42/django-blog-zinnia/jobs/351805880
The older builds have always worked.
Regards