# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2017-09-20 18:33
from __future__ import unicode_literals

import hashlib

from django.db import migrations
from django.utils.encoding import force_bytes


def get_guid(apps, schema_editor):
    Episode = apps.get_model('podcast', 'Episode')
    for episode in Episode.objects.all():
        bytes_id = force_bytes(episode.id)
        episode.guid = hashlib.sha256(bytes_id).hexdigest()
        episode.save(update_fields=['guid'])


class Migration(migrations.Migration):

    dependencies = [
        ('podcast', '0005_episode_guid'),
    ]

    operations = [
        migrations.RunPython(get_guid, reverse_code=migrations.RunPython.noop),
    ]
