Browse Source

Conserta erro de migração Bloco (#2792)

pull/2811/head
Edward 6 years ago
committed by Leandro Roberto
parent
commit
f7349b4781
  1. 65
      sapl/parlamentares/migrations/0029_auto_20190517_1531.py

65
sapl/parlamentares/migrations/0029_auto_20190517_1531.py

@ -13,22 +13,55 @@ class Migration(migrations.Migration):
operations = [ operations = [
migrations.RunSQL(""" migrations.RunSQL("""
update base_autor INSERT INTO django_content_type (app_label, model)
set tipo_id = (select id SELECT 'parlamentares', 'bloco'
from base_tipoautor WHERE NOT EXISTS (SELECT id
where content_type_id = (select id FROM django_content_type
from django_content_type WHERE app_label = 'parlamentares' AND model = 'bloco');
where app_label = 'parlamentares' and model = 'bloco'))
where tipo_id = (select id
from base_tipoautor
where content_type_id = (select id
from django_content_type
where app_label = 'sessao' and model = 'bloco'));
"""), """),
migrations.RunSQL(""" migrations.RunSQL("""
delete from base_tipoautor INSERT INTO base_tipoautor (descricao, content_type_id)
where content_type_id = (select id SELECT 'Bloco Parlamentar', (SELECT id
from django_content_type FROM django_content_type
where app_label = 'sessao' and model = 'bloco') WHERE app_label = 'parlamentares' AND model = 'bloco')
""") WHERE NOT EXISTS (SELECT id
FROM base_tipoautor
WHERE content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'parlamentares' AND model = 'bloco'));
"""),
migrations.RunSQL("""
UPDATE auth_permission
SET content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'parlamentares' AND model = 'bloco')
WHERE content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'sessao' AND model = 'bloco')
AND NOT EXISTS (SELECT id
FROM django_content_type
WHERE app_label = 'parlamentares' AND model = 'bloco');
"""),
migrations.RunSQL("""
UPDATE base_autor
SET tipo_id = (SELECT id
FROM base_tipoautor
WHERE content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'parlamentares' AND model = 'bloco')),
content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'parlamentares' AND model = 'bloco')
WHERE tipo_id = (SELECT id
FROM base_tipoautor
WHERE content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'sessao' AND model = 'bloco'));
"""),
migrations.RunSQL("""
DELETE FROM base_tipoautor
WHERE content_type_id = (SELECT id
FROM django_content_type
WHERE app_label = 'sessao' AND model = 'bloco');
"""),
] ]

Loading…
Cancel
Save