misc: migrate dashboard/tile foreign keys (#...)

This commit is contained in:
Frédéric Péters 2018-01-08 19:08:19 +01:00
parent 85cf3e767f
commit e626863893
1 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('dashboard', '0005_auto_20180107_1355'),
('data', '0033_auto_20180107_1259'),
]
operations = [
migrations.RunSQL("""
UPDATE dashboard_tile SET dashboard_id =
(SELECT data_cellbase.id
FROM data_cellbase
WHERE data_cellbase.subclassid = dashboard_tile.dashboard_id
AND data_cellbase.subclass = 13);"""),
# this assumes tile cells are always of type "configjsoncell", this is
# not theorically true but it's close enough to the current truth.
migrations.RunSQL("""
UPDATE dashboard_tile SET cell_pk =
(SELECT data_cellbase.id
FROM data_cellbase
WHERE data_cellbase.subclassid = dashboard_tile.cell_pk
AND data_cellbase.subclass = 2);"""),
]