On Tuesday 30 May 2017 06:09 PM, Senthil Kumaran S wrote:
> I tested the new version ie., test2 and got a traceback as shown here -
> http://paste.debian.net/952939/

When combined with the attached patch for lava-server the migration
works fine as seen here - http://paste.debian.net/952953/

Thank You.
-- 
Senthil Kumaran
http://www.stylesen.org/
http://www.sasenthilkumaran.com/
From dda5f10642678d769ca300325feae771b30baceb Mon Sep 17 00:00:00 2001
From: Senthil Kumaran S <senthil.kuma...@linaro.org>
Date: Mon, 29 May 2017 17:39:39 +0530
Subject: [PATCH] Fix migrations from Debian Jessie to Stretch and ensure smooth upgrade.

Django 1.10.1 introduces consistency checks which introduces dependency
problem with the order in which lava_scheduler_app and linaro_django_xmlrpc
initial migrations gets applied.

Related bugs:
* Debian:
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863267
  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=847277

* Django:
  https://code.djangoproject.com/ticket/28250

Change-Id: I4ea7632d9e98d6fd5e01aca65c37410ce7dd628a
---

diff --git a/lava_scheduler_app/migrations/0001_initial.py b/lava_scheduler_app/migrations/0001_initial.py
index e321682..eda8572 100644
--- a/lava_scheduler_app/migrations/0001_initial.py
+++ b/lava_scheduler_app/migrations/0001_initial.py
@@ -1,12 +1,26 @@
 # -*- coding: utf-8 -*-
 from __future__ import unicode_literals
 
-from django.db import models, migrations
+from django.db import models, migrations, DEFAULT_DB_ALIAS, connections
+from django.db.migrations.recorder import MigrationRecorder
 import django.db.models.deletion
 from django.conf import settings
 import lava_scheduler_app.models
 
 
+connection = connections[DEFAULT_DB_ALIAS]
+recorder = MigrationRecorder(connection)
+linaro_django_xmlrpc_applied = False
+lava_scheduler_app_applied = False
+for app, name in recorder.applied_migrations():
+    if app == 'linaro_django_xmlrpc' and name == '0001_initial':
+        linaro_django_xmlrpc_applied = True
+    if app == 'lava_scheduler_app' and name == '0001_initial':
+        lava_scheduler_app_applied = True
+if not linaro_django_xmlrpc_applied and lava_scheduler_app_applied:
+    recorder.record_applied('linaro_django_xmlrpc', '0001_initial')
+
+
 class Migration(migrations.Migration):
 
     dependencies = [

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to