diff --git a/server/books/migrate_document_model.py b/server/books/migrate_document_model.py index fa465184..fff67887 100644 --- a/server/books/migrate_document_model.py +++ b/server/books/migrate_document_model.py @@ -1,10 +1,15 @@ -from wagtail.documents.models import Document from .models.custom_document import CustomDocument def migrate_documents_to_custom_document_model(dryrun=False): - all_documents = Document.objects.all() + try: + from wagtail.documents.models import Document + all_documents = Document.objects.all() + except Exception as e: + # new databases do not have the table for the standart wagtail documents there fore the migration is not + # necessary. Mainly + return print(f"Found {all_documents.count()} Documents") for document in all_documents: diff --git a/server/books/migrations/0036_migrate_to_customdocumentmodel.py b/server/books/migrations/0036_migrate_to_customdocumentmodel.py deleted file mode 100644 index 50e05dfd..00000000 --- a/server/books/migrations/0036_migrate_to_customdocumentmodel.py +++ /dev/null @@ -1,22 +0,0 @@ - -from django.db import migrations - -from books.migrate_document_model import migrate_documents_to_custom_document_model - - -def forwards_func(apps, schema_editor): - migrate_documents_to_custom_document_model() - - -def reverse_func(apps, schema_editor): - pass - - -class Migration(migrations.Migration): - dependencies = [ - ('books', '0035_auto_20220728_0848'), - ] - - operations = [ - migrations.RunPython(forwards_func, reverse_func), - ]