-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Description
I'm upgrading Django CMS from v3.11.1 to v5.1.0, and it throws a migration error with cms.0027_title_placeholders_data_migration when I try to run db migration.
The error message is "django.db.utils.ProgrammingError: column "cms_placeholder.slot" must appear in the GROUP BY clause or be used in an aggregate function"
Steps to reproduce
- Replace
django-cms==3.11.1
withdjango-cms==5.1.0
in the requirements.txt - Run the command for installing packages:
pip install -r requirements.txt
- Run the db migration:
python manage.py migrate
- See error:
Running migrations:
Applying cms.0027_title_placeholders_data_migration...Traceback (most recent call last):
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
psycopg2.errors.GroupingError: column "cms_placeholder.slot" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "cms_placeholder"."id", "cms_placeholder"."slot", "cm...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/opt/JP-Website/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/cms/migrations/0027_title_placeholders_data_migration.py", line 109, in forwards
old_placeholders.filter(plugin_count=0).delete()
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/query.py", line 1147, in delete
collector.collect(del_query)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/deletion.py", line 284, in collect
new_objs = self.add(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/deletion.py", line 126, in add
if not objs:
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/query.py", line 412, in __bool__
self._fetch_all()
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/query.py", line 1881, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/query.py", line 91, in __iter__
results = compiler.execute_sql(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/models/sql/compiler.py", line 1560, in execute_sql
cursor.execute(sql, params)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/backends/utils.py", line 102, in execute
return super().execute(sql, params)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/backends/utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/opt/JP-Website/myenv/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: column "cms_placeholder.slot" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: SELECT "cms_placeholder"."id", "cms_placeholder"."slot", "cm...
Expected behaviour
The migration command should run successfully.
Actual behaviour
It throws an error with cms.0027_title_placeholders_data_migration
Additional information (CMS/Python/Django versions)
CMS version: 5.1.0
Django version: v4.2
Python version: 3.10.12
Do you want to help fix this issue?
- Yes, I want to help fix this issue and I will join the channel #pr-reviews on the Discord Server to confirm with the community that a PR is welcome.
- No, I only want to report the issue.
Metadata
Metadata
Assignees
Labels
No labels