Browse Source

Comando do manage.py para recriar constraints

Signed-off-by: Luciano Almeida <lucianoalmeida@interlegis.leg.br>
pull/989/head
Luciano Almeida 8 years ago
parent
commit
7f24bea073
  1. 12
      sapl/legacy/management/commands/recria_constraints.py
  2. 4
      sapl/legacy/migration.py
  3. 6
      sapl/legacy/scripts/migra_um_db.sh

12
sapl/legacy/management/commands/recria_constraints.py

@ -0,0 +1,12 @@
from django.core.management.base import BaseCommand
from sapl.legacy.migration import recria_constraints
class Command(BaseCommand):
help = (u'Recria constraints do PostgreSQL excluidas durante '
'migração de dados')
def handle(self, *args, **options):
recria_constraints()

4
sapl/legacy/migration.py

@ -236,7 +236,7 @@ def delete_constraints(model):
(table, r[0]))
def recreate_constraints():
def recria_constraints():
constraints = Constraint.objects.all()
for con in constraints:
if con.tipo_constraint == 'one_to_one':
@ -459,7 +459,7 @@ class DataMigrator:
for obj in self.to_delete:
msg = 'A entrada de PK %s da model %s não pode ser ' \
'excluida' % (obj.pk, obj._meta.model_name)
descricao = 'Um ou mais objetos protegidos '
descricao = 'Um ou mais objetos protegidos'
warn(msg + ' => ' + descricao)
save_relation(obj=obj, problema=msg,
descricao=descricao, eh_stub=False)

6
sapl/legacy/scripts/migra_um_db.sh

@ -23,3 +23,9 @@ echo "--- MIGRACAO DE DADOS ---" | tee -a $LOG
echo >> $LOG
DATABASE_NAME=$1 ./manage.py migracao_25_31 -f --settings sapl.legacy_migration_settings |& tee -a $LOG
echo >> $LOG
echo "--- RECRIANDO CONSTRAINTS ---" | tee -a $LOG
echo >> $LOG
DATABASE_NAME=$1 ./manage.py recria_constraints --settings sapl.legacy_migration_settings |& tee -a $LOG
echo >> $LOG

Loading…
Cancel
Save