django-q
django-q copied to clipboard
post-upgrade - no such column: django_q_schedule
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!
I downgraded django-q back to 1.3.5 and everything is working again. Not sure what the issue is exactly.
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"
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 if you're having a problem during
migrate
, it's possibly due to trying to use theschedule()
function orSchedule
model during import time. Try moving that code to run later, for example during a customqcluster
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.