Skip to content

fix: add migration to remove old ckeditor table #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 12, 2025
6 changes: 5 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,17 @@ Upgrading from djangocms-text-ckeditor
--------------------------------------

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

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

**Attention**: The migration command also deletes djangocms-text-ckeditor's
tables from the database (to avoid referential integrity issues). To be on
the safe side, make a backup of its content.

When transitioning from CKEditor4 to Tiptap as the rich text editor in your
project, consider the following points:

Expand Down
1 change: 0 additions & 1 deletion djangocms_text/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,6 @@ def get_messages(self, request):
@lru_cache
def get_child_plugin_candidates(cls, *args, **kwargs):
"""

This method is a class method that returns a list of child plugin candidates for a given slot and page.

Parameters:
Expand Down
23 changes: 23 additions & 0 deletions djangocms_text/migrations/0004_remove_old_ckeditor_table.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.db import migrations


def drop_table_if_exists(apps, schema_editor):
table_name = "djangocms_text_ckeditor_text"

Check warning on line 5 in djangocms_text/migrations/0004_remove_old_ckeditor_table.py

View check run for this annotation

Codecov / codecov/patch

djangocms_text/migrations/0004_remove_old_ckeditor_table.py#L5

Added line #L5 was not covered by tests
if table_name in schema_editor.connection.introspection.table_names():
if schema_editor.connection.vendor == "postgresql":
schema_editor.execute("DROP TABLE IF EXISTS djangocms_text_ckeditor_text CASCADE;")

Check warning on line 8 in djangocms_text/migrations/0004_remove_old_ckeditor_table.py

View check run for this annotation

Codecov / codecov/patch

djangocms_text/migrations/0004_remove_old_ckeditor_table.py#L8

Added line #L8 was not covered by tests
else:
schema_editor.execute("DROP TABLE IF EXISTS djangocms_text_ckeditor_text;")

Check warning on line 10 in djangocms_text/migrations/0004_remove_old_ckeditor_table.py

View check run for this annotation

Codecov / codecov/patch

djangocms_text/migrations/0004_remove_old_ckeditor_table.py#L10

Added line #L10 was not covered by tests


class Migration(migrations.Migration):
dependencies = [
("djangocms_text", "0003_auto_20240702_1409"),
]

operations = [
migrations.RunPython(
code=drop_table_if_exists,
reverse_code=migrations.RunPython.noop,
),
]