From 45676787a7648da9b6b8dc83d3f4138702de900c Mon Sep 17 00:00:00 2001 From: Ivlev Denis Date: Mon, 5 Feb 2018 19:17:24 +0300 Subject: [PATCH] Fix present comments --- .../migrations/0022_auto_20180205_1615.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 apps/course/migrations/0022_auto_20180205_1615.py diff --git a/apps/course/migrations/0022_auto_20180205_1615.py b/apps/course/migrations/0022_auto_20180205_1615.py new file mode 100644 index 00000000..87bc49b7 --- /dev/null +++ b/apps/course/migrations/0022_auto_20180205_1615.py @@ -0,0 +1,35 @@ +# Generated by Django 2.0.2 on 2018-02-05 16:15 + +from django.db import migrations +from django.contrib.contenttypes.models import ContentType + + +def fwrd_func(apps, schema_editor): + CourseComment = apps.get_model('course', 'CourseComment') + LessonComment = apps.get_model('course', 'LessonComment') + db_alias = schema_editor.connection.alias + if CourseComment.objects.using(db_alias).all().exists(): + coursecomment_content_type = ContentType.objects.get( + app_label='course', model='coursecomment', + ) + CourseComment.objects.using(db_alias).all().update( + polymorphic_ctype=coursecomment_content_type, + ) + if LessonComment.objects.using(db_alias).all().exists(): + lessoncomment_content_type = ContentType.objects.get( + app_label='course', model='lessoncomment', + ) + LessonComment.objects.using(db_alias).all().update( + polymorphic_ctype=lessoncomment_content_type, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('course', '0021_auto_20180205_1559'), + ] + + operations = [ + migrations.RunPython(fwrd_func) + ]