Skip to content

Commit 65bcf8f

Browse files
committed
Fix exception handling
1 parent 7e64671 commit 65bcf8f

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

djangocms_text/migrations/0003_auto_20240702_1409.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Django 3.2.25 on 2024-07-02 14:09
22

3-
from django.db import migrations, models, ProgrammingError
3+
from django.db import migrations, models, OperationalError
44

55

66
def migrate_text_ckeditor_fields(apps, schema_editor):
@@ -23,12 +23,14 @@ class Meta:
2323
try:
2424
existing_texts = Text_Text.objects.all().values_list("cmsplugin_ptr_id", flat=True)
2525
qs = CKEditorText.objects.using(schema_editor.connection.alias).exclude(cmsplugin_ptr_id__in=existing_texts)
26-
except ProgrammingError:
27-
return
28-
Text_Text.objects.using(schema_editor.connection.alias).bulk_create(
29-
Text_Text(body=ckeditor_text.body, rte="text_ckeditor4", cmsplugin_ptr_id=ckeditor_text.cmsplugin_ptr_id)
30-
for ckeditor_text in qs
31-
)
26+
Text_Text.objects.using(schema_editor.connection.alias).bulk_create(
27+
Text_Text(body=ckeditor_text.body, rte="text_ckeditor4", cmsplugin_ptr_id=ckeditor_text.cmsplugin_ptr_id)
28+
for ckeditor_text in qs
29+
)
30+
except OperationalError as e:
31+
if "no such table" in str(e):
32+
return
33+
raise e
3234

3335

3436
class Migration(migrations.Migration):

0 commit comments

Comments
 (0)