Skip to content
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

fix: add migration to remove old ckeditor table #61

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ 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``
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,
),
]