django-dbfilestorage/dbfilestorage/migrations/0008_auto_20170206_1945.py
Tyrel Souza 8f811db7c8 Change pk (#35)
* add new primary_key field.

* Add new field, populate data, change to being pk, change name, double length of name field, and set it to unique

* change version, and add new migration

* bump down the size, 767/4 = 191

* update readme

* remove models.py comment
2017-02-06 15:31:40 -05:00

24 lines
575 B
Python

# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2017-02-06 19:45
from __future__ import unicode_literals
from django.db import migrations
def _fix_pk(apps, schema_editor):
""" Set the primary_key to be a series """
DBFile = apps.get_model("dbfilestorage", "DBFile")
for idx, dbf in enumerate(DBFile.objects.all()):
dbf.primary_key = idx+1
dbf.save()
class Migration(migrations.Migration):
dependencies = [
('dbfilestorage', '0007_auto_20170206_1940'),
]
operations = [
migrations.RunPython(_fix_pk)
]