Repository: learningequality/kolibri
Issue: Can't add fields to Collection model

<!--
Instructions:
 * Fill out the sections below, replace …'s with information about your issue
 * Use the 'preview' function above this text box to verify formatting before submitting
-->

### Observed behavior
<!--
Description of the behavior that was observed, including screenshots or other references when applicable
-->

A field was added to the Collection model, and the custom migration where the DeviceOwner is removed (`0004`) is broken because the field they added has not been migrated at the time of accessing the most up to date "Real" `Facility` model (https://github.com/learningequality/kolibri/blob/develop/kolibri/core/auth/migrations/0004_auto_20170816_1607.py#L21).
Thus, Kolibri is not able to migrate properly when adding fields to the `Collection` model. 

### Expected behavior
<!--
Description of what behavior was expected but did not occur
-->

Kolibri should be able to migrate successfully.

### Developer-facing consequences
<!--
Implications and real-world consequences for learners, coaches, admins, and other users of the application
-->

Won't be able to add fields to the `Collection` model in the future.

### Steps to reproduce
<!--
Precise steps that someone else can follow in order to see this behavior
-->

First observed here https://github.com/learningequality/kolibri/pull/5373

### Possible Solution

Fix the migration `0004` to prevent it from erring out when accessing the Real `Facility` model, and forcefully/manually squash migrations so that device owners never get created.


Changed files:
kolibri/core/auth/migrations/0004_auto_20170816_1607.py

diff --git a/kolibri/core/auth/migrations/0004_auto_20170816_1607.py b/kolibri/core/auth/migrations/0004_auto_20170816_1607.py
index 4f3465597d..a32777323c 100644
--- a/kolibri/core/auth/migrations/0004_auto_20170816_1607.py
+++ b/kolibri/core/auth/migrations/0004_auto_20170816_1607.py
@@ -2,9 +2,7 @@
 # Generated by Django 1.9.7 on 2017-08-16 23:07
 from __future__ import unicode_literals
 
-import django.core.validators
 from django.db import migrations
-from django.db import models
 
 from kolibri.core.auth.constants.role_kinds import ADMIN
 
@@ -18,21 +16,22 @@ def device_owner_to_super_user(apps, schema_editor):
 
     # The get_default_facility method now requires database access to another model that does not exist yet for
     # this migration, so just defer to the old behaviour.
-    real_default_facility = RealFacility.objects.first()
+
     # Can't do much if no facilities exist, as no facility to FK the users onto
-    if real_default_facility:
+    if RealFacility.objects.exists():
+        facility = RealFacility.objects.values("id", "dataset_id")[0]
         DeviceOwner = apps.get_model("kolibriauth", "DeviceOwner")
         FacilityUser = apps.get_model("kolibriauth", "FacilityUser")
         Facility = apps.get_model("kolibriauth", "Facility")
-        default_facility = Facility.objects.get(pk=real_default_facility.id)
+        default_facility = Facility.objects.get(pk=facility["id"])
         DevicePermissions = apps.get_model("device", "DevicePermissions")
         DeviceSettings = apps.get_model("device", "DeviceSettings")
         Role = apps.get_model("kolibriauth", "Role")
         for device_owner in DeviceOwner.objects.all():
-            dataset_id = real_default_facility.dataset_id
+            dataset_id = facility["dataset_id"]
             real_superuser = RealFacilityUser(
                 username=device_owner.username,
-                facility=real_default_facility,
+                facility_id=facility["id"],
                 dataset_id=dataset_id,
             )
             uuid = real_superuser.calculate_uuid()
@@ -52,12 +51,12 @@ def device_owner_to_super_user(apps, schema_editor):
             )
             real_role = RealRole(
                 user_id=superuser.id,
-                collection=real_default_facility,
+                collection_id=facility["id"],
                 kind=ADMIN,
                 dataset_id=dataset_id,
             )
             role_uuid = real_role.calculate_uuid()
-            role = Role.objects.create(
+            Role.objects.create(
                 user=superuser,
                 collection=default_facility,
                 kind=ADMIN,