@@ -0,0 +1,1053 @@
+from __future__ import print_function%0A%0Afrom django.core.management.base import BaseCommand%0A%0Afrom pillowtop.models import DjangoPillowCheckpoint, KafkaCheckpoint, str_to_kafka_seq%0A%0A%0Aclass Command(BaseCommand):%0A    %22%22%22%0A    One off migration for kafka pillow checkpoints before partitioning%0A    %22%22%22%0A    help = %22Migrate the kafka pillow checkpoints%22%0A%0A    def handle(self, **options):%0A        for checkpoint in DjangoPillowCheckpoint.objects.filter(sequence_format='json'):%0A            try:%0A                kafka_seq = str_to_kafka_seq(checkpoint.sequence)%0A            except ValueError:%0A                print(%22unable to migrate %7B%7D%22, checkpoint.checkpoint_id)%0A            else:%0A                for topic_partition, offset in kafka_seq.items():%0A                    KafkaCheckpoint.objects.update_or_create(%0A                        checkpoint_id=checkpoint.checkpoint_id,%0A                        topic=topic_partition.topic,%0A                        partition=topic_partition.partition,%0A                        defaults=%7B'offset': offset%7D%0A                    )%0A

add management command to migrate pillow checkpoints