From 4776d4a514fac14ac95570434e33061c04f171d3 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Fri, 8 Sep 2017 10:28:23 -0300 Subject: [PATCH] Remove unique_together de TipoProposicao --- .../migrations/0015_auto_20170908_1024.py | 37 +++++++++++++++++++ sapl/materia/models.py | 1 - 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 sapl/materia/migrations/0015_auto_20170908_1024.py diff --git a/sapl/materia/migrations/0015_auto_20170908_1024.py b/sapl/materia/migrations/0015_auto_20170908_1024.py new file mode 100644 index 000000000..3332b6504 --- /dev/null +++ b/sapl/materia/migrations/0015_auto_20170908_1024.py @@ -0,0 +1,37 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.13 on 2017-09-08 10:24 +from __future__ import unicode_literals + +from django.db import migrations + +from sapl.materia.models import TipoProposicao + + +class AlterUniqueTogetherFixConstraintInexistente( + migrations.AlterUniqueTogether): + + def database_forwards(self, + app_label, schema_editor, from_state, to_state): + constraint_names = schema_editor._constraint_names( + TipoProposicao, ['content_type_id', 'object_id'], unique=True) + if constraint_names: + # por alguma razão a constraint não existe em alguns bancos + # se ela existir continua a exetução normal + super(AlterUniqueTogetherFixConstraintInexistente, + self).database_forwards( + app_label, schema_editor, from_state, to_state + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0014_auto_20170905_0818'), + ] + + operations = [ + AlterUniqueTogetherFixConstraintInexistente( + name='tipoproposicao', + unique_together=set([]), + ), + ] diff --git a/sapl/materia/models.py b/sapl/materia/models.py index 43027bea9..fda53d192 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -66,7 +66,6 @@ class TipoProposicao(models.Model): class Meta: verbose_name = _('Tipo de Proposição') verbose_name_plural = _('Tipos de Proposições') - unique_together = (('content_type', 'object_id'), ) def __str__(self): return self.descricao