Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post-upgrade - no such column: django_q_schedule #634

Open
smierd opened this issue Dec 7, 2021 · 4 comments
Open

post-upgrade - no such column: django_q_schedule #634

smierd opened this issue Dec 7, 2021 · 4 comments

Comments

@smierd
Copy link

smierd commented Dec 7, 2021

Hello,

I am getting the following error after upgrading my system
no such column: django_q_schedule.cluster

  • python 3.8.5 to 3.9.6
  • django 3.1.1 to 3.2.6
  • django-q 1.3.5 to 1.3.9

I have made no other code changes. When trying to open the Scheduled Tasks from the admin panel, I get the error above. The qcluster console shows the error every 30s, in the shell, trying to run

from django_q.models import * Schedule.objects.all()

sqlite3.OperationalError: no such column: django_q_schedule.cluster

It stopped working after my upgrades but I did them all together (rookie mistake) so I am not sure which is the cause. Wondering if I need to roll back of if there's an easy solution.

Thank you!

@smierd
Copy link
Author

smierd commented Dec 9, 2021

I downgraded django-q back to 1.3.5 and everything is working again. Not sure what the issue is exactly.

@youri-ds
Copy link

youri-ds commented Jan 20, 2022

Same issue here with postgres, the upgrade from 1.3.5 to 1.3.9 has failed but the issue starts with 1.3.6

I suspect the PR #555 because of cluster field.

And the issue is reported in #610 as well.

python manage.py migrate is reporting the same error "column django_q_schedule.cluster does not exist"

@adamchainz
Copy link

PR #555 includes a migration file. After updating to the latest version, did you run ./manage.py migrate?

@youri-ds if you're having a problem during migrate, it's possibly due to trying to use the schedule() function or Schedule model during import time. Try moving that code to run later, for example during a custom qcluster management command. Here's an example I just wrote for a project:

from django_q.management.commands.qcluster import Command as BaseCommand
from django_q.models import Schedule

from example import tasks


class Command(BaseCommand):
    def handle(self, *args, **kwargs):
        ensure_schedule_updated()
        super().handle(*args, **kwargs)


def ensure_schedule_updated():
    def path(func):
        return f"{func.__module__}.{func.__name__}"

    Schedule.objects.update_or_create(
        name="run_debug_print",
        defaults={
            "func": path(tasks.debug_print),
            "schedule_type": Schedule.MINUTES,
            "minutes": 5,
        },
    )

@youri-ds
Copy link

youri-ds commented Sep 7, 2022

@youri-ds if you're having a problem during migrate, it's possibly due to trying to use the schedule() function or Schedule model during import time. Try moving that code to run later, for example during a custom qcluster management command. Here's an example I just wrote for a project:

Hi Adam, I think your are right because I have some initialization code.
I will upgrade and test your code when I have the time.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants