question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django migrations remove model CompletedTask

See original GitHub issue

When I run migrations I got the output:

  • Remove field creator_content_type from completedtask
  • Delete model CompletedTask

and migration:

class Migration(migrations.Migration):

    dependencies = [
        ('background_task', '0001_initial'),
    ]

    operations = [
        migrations.RemoveField(
            model_name='completedtask',
            name='creator_content_type',
        ),
        migrations.DeleteModel(
            name='CompletedTask',
        ),
    ]

and all gone good but when I run tasks django raise an error django.db.utils.OperationalError: no such table: background_task_completedtask

Why django remove this table and how can I avoid it? Should I just ignore this migration or there is some more clever way?

P.S. I already check simial questions but I didn’t find the solution.

I can fake this migration but got another problem. django-background-tasks register each task two times (I call only one time). Could you suggest how to cook it?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
wingedcommented, Dec 20, 2018

I had the same problem on Django 2.1. Seems like it doesn’t correctly detect the model in background_task.models_completed. Will send a PR once I’m sure it looks good (basically it moves the model and queryset classes from background_task.models_completed to background_task.models)

1reaction
mctinetticommented, Apr 17, 2018

I also have this issue. Running django 1.11.12 and django-background-tasks (1.1.13), using a virtualenv- For the moment I’m just removing this from the migration file: 0003_auto_20180417_1203.py

migrations.DeleteModel(
            name='CompletedTask',
        ),
Read more comments on GitHub >

github_iconTop Results From Across the Web

Stop Django background-task from deleting completed_task ...
1. If you go through each of your migration files, do any of them look like they will delete that table? · The...
Read more >
How to safely remove Django model and its relations
So the only way to preserve the data of old models is to write a data migration to transfer both models data and...
Read more >
Migrations - Django documentation
Workflow¶. Django can create migrations for you. Make changes to your models - say, add a field and remove a model - and...
Read more >
How to Reset Migrations - Simple is Better Than Complex
Scenario 2: · 1. Make sure your models fits the current database schema · 2. Clear the migration history for each app ·...
Read more >
Django Migrations: A Primer - Real Python
In Django, database migrations usually go hand in hand with models: ... SQL is also used to create, change, and delete the database...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found