Skip to content

Commit bbdc031

Browse files
earthcomfyfsbraun
andauthored
fix: add migration to remove old ckeditor table (#61)
Co-authored-by: Fabian Braun <fsbraun@gmx.de>
1 parent 3ef1b78 commit bbdc031

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,17 @@ Upgrading from djangocms-text-ckeditor
5959
--------------------------------------
6060

6161
djangocms-text's migrations automatically migrate existing text plugins
62-
from djangocms-text-ckeditor. All you have to do is:
62+
from djangocms-text-ckeditor, and clean up old tables. All you have to do is:
6363

6464
* uninstall ``djangocms-text-ckeditor``
6565
* remove ``djangocms_text_ckeditor`` from ``INSTALLED_APPS``
6666
* add ``djangocms_text`` to ``INSTALLED_APPS`` (see above)
6767
* run ``python -m manage migrate djangocms_text``
6868

69+
**Attention**: The migration command also deletes djangocms-text-ckeditor's
70+
tables from the database (to avoid referential integrity issues). To be on
71+
the safe side, make a backup of its content.
72+
6973
When transitioning from CKEditor4 to Tiptap as the rich text editor in your
7074
project, consider the following points:
7175

djangocms_text/cms_plugins.py

-1
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,6 @@ def get_messages(self, request):
581581
@lru_cache
582582
def get_child_plugin_candidates(cls, *args, **kwargs):
583583
"""
584-
585584
This method is a class method that returns a list of child plugin candidates for a given slot and page.
586585
587586
Parameters:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from django.db import migrations
2+
3+
4+
def drop_table_if_exists(apps, schema_editor):
5+
table_name = "djangocms_text_ckeditor_text"
6+
if table_name in schema_editor.connection.introspection.table_names():
7+
if schema_editor.connection.vendor == "postgresql":
8+
schema_editor.execute("DROP TABLE IF EXISTS djangocms_text_ckeditor_text CASCADE;")
9+
else:
10+
schema_editor.execute("DROP TABLE IF EXISTS djangocms_text_ckeditor_text;")
11+
12+
13+
class Migration(migrations.Migration):
14+
dependencies = [
15+
("djangocms_text", "0003_auto_20240702_1409"),
16+
]
17+
18+
operations = [
19+
migrations.RunPython(
20+
code=drop_table_if_exists,
21+
reverse_code=migrations.RunPython.noop,
22+
),
23+
]

0 commit comments

Comments
 (0)