Skip to content

Commit a6fb21c

Browse files
committed
Fix data migration
1 parent 043ee98 commit a6fb21c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

djangocms_snippet/migrations/0010_cms4_grouper_version_data_migration.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from django.apps import apps as global_apps
2+
from django.conf import settings
23
from django.contrib.contenttypes.management import create_contenttypes
34
from django.db import migrations
45

@@ -24,13 +25,13 @@ def cms4_grouper_version_migration(apps, schema_editor):
2425
ContentType = apps.get_model('contenttypes', 'ContentType')
2526
Snippet = apps.get_model('djangocms_snippet', 'Snippet')
2627
SnippetGrouper = apps.get_model('djangocms_snippet', 'SnippetGrouper')
27-
User = apps.get_model('auth', 'User')
28+
User = apps.get_model(*settings.AUTH_USER_MODEL.split('.'))
2829

2930
snippet_contenttype = ContentType.objects.get(app_label='djangocms_snippet', model='snippet')
3031
snippet_queryset = Snippet.objects.all()
3132

3233
# Get a migration user to create a version.
33-
if djangocms_versioning_config_enabled and djangocms_versioning_installed:
34+
if djangocms_versioning_config_enabled and djangocms_versioning_installed and len(snippet_queryset):
3435
Version = apps.get_model('djangocms_versioning', 'Version')
3536

3637
migration_user = User.objects.get(id=DJANGOCMS_SNIPPET_VERSIONING_MIGRATION_USER_ID)

0 commit comments

Comments
 (0)