Closed Bug 899271 Opened 11 years ago Closed 11 years ago

Migration 226 doesn't work without a DB dump.

Categories

(support.mozilla.org :: Code Quality, task)

x86_64
Linux
task
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mythmon, Assigned: willkg)

References

Details

(Whiteboard: p=0 u=dev c=codequality s=2013.16)

Migration 226 was written assuming a production-like database was loaded, and this causes problems for code contributors, because it errors out if that is not true. This migration should be made more robust.

This is probably some simple try/catching => 1pt.

This is the traceback fxa got when he tried to run the migrations:

    Running .py migation 226:
    /root/workspace/kitsune/venv/bin/python -B manage.py runscript migrations.226-retopic-questions
    Error: Had trouble running this: /root/workspace/kitsune/venv/bin/python -B manage.py runscript migrations.226-retopic-questions
    stdout: Exception while running run() in 'migrations.226-retopic-questions'
    Traceback (most recent call last):
      File "manage.py", line 47, in <module>
        execute_manager(settings)
      File "/root/workspace/kitsune/vendor/src/django/django/core/management/__init__.py", line 459, in execute_manager
        utility.execute()
      File "/root/workspace/kitsune/vendor/src/django/django/core/management/__init__.py", line 382, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/root/workspace/kitsune/vendor/src/django/django/core/management/base.py", line 196, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/root/workspace/kitsune/vendor/src/django/django/core/management/base.py", line 232, in execute
        output = self.handle(*args, **options)
      File "/root/workspace/kitsune/vendor/src/django-extensions/django_extensions/management/commands/runscript.py", line 158, in handle
        run_script(mod, *script_args)
      File "/root/workspace/kitsune/vendor/src/django-extensions/django_extensions/management/commands/runscript.py", line 83, in run_script
        mod.run(*script_args)
      File "/root/workspace/kitsune/migrations/226-retopic-questions.py", line 14, in run
        product = Product.objects.get(slug=product_slug)
      File "/root/workspace/kitsune/vendor/src/django/django/db/models/manager.py", line 131, in get
        return self.get_query_set().get(*args, **kwargs)
      File "/root/workspace/kitsune/vendor/src/django/django/db/models/query.py", line 366, in get
        % self.model._meta.object_name)
    kitsune.products.models.DoesNotExist: Product matching query does not exist.
     
    stderr: None
    returncode: 1
Blocks: 905834
This keeps popping up. Sticking it in the next sprint.
Whiteboard: p=1 u=dev c=kb s=2013.backlog → p=1 u=dev c=kb s=2013.17
I keep meaning to fix this and write some scaffolding so I can test migrations against empty databases going forward. I'll grab this and do it now.

Making it 0 points because I was looking at it last week when I bumped into it. Pretty sure it's an easy fix.
Assignee: nobody → willkg
Whiteboard: p=1 u=dev c=kb s=2013.17 → p=0 u=dev c=kb s=2013.16
Landed in master: https://github.com/mozilla/kitsune/commit/a3f08a6

This doesn't need to be pushed so I'm closing it now.
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Whiteboard: p=0 u=dev c=kb s=2013.16 → p=0 u=dev c=codequality s=2013.16
You need to log in before you can comment on or make changes to this bug.