Skip to content

Commit

Permalink
Set is_root=True for old folders set as root_node for existing NodeSe…
Browse files Browse the repository at this point in the history
…ttings

[#PLAT-578]
  • Loading branch information
erinspace committed Jul 12, 2018
1 parent 432b8ea commit 191e041
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions osf/migrations/0117_set_is_root.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-11 18:05
from __future__ import unicode_literals

from django.db import migrations


def set_is_root(state, *args, **kwargs):
OsfStorageFolder = state.get_model('osf', 'osfstoragefolder')
OsfStorageFolder.objects.filter(nodesettings__isnull=False, is_root__isnull=True).update(is_root=True)


def unset_is_root(state, *args, **kwargs):
state.get_model('osf', 'osfstoragefolder').objects.filter(is_root=True).update(is_root=None)


class Migration(migrations.Migration):

dependencies = [
('osf', '0116_merge_20180706_0901'),
]

operations = [
migrations.RunPython(set_is_root, unset_is_root)
]

0 comments on commit 191e041

Please sign in to comment.