sso/user/migrations/0008_user_hashed_uuid.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.20 on 2019-05-14 15:20
from __future__ import unicode_literals
import uuid
from django.conf import settings
from django.db import migrations, models
from core.helpers import createHash
class Migration(migrations.Migration):
def add_hashed_uuid(apps, schema_editor):
User = apps.get_model(*settings.AUTH_USER_MODEL.split('.'))
# user = apps.get_model('sso', 'User')
for row in User.objects.all():
row.hashed_uuid = createHash(uuid.uuid4())
row.save(update_fields=['hashed_uuid'])
dependencies = [
('user', '0007_userprofile'),
]
operations = [
migrations.AddField(
model_name='user',
name='hashed_uuid',
field=models.CharField(default='', help_text="a hash representation of the object's UUID", max_length=200),
),
migrations.RunPython(add_hashed_uuid, reverse_code=migrations.RunPython.noop),
]