From 09782a7556995ea61e2c2aec3ebc4da986079118 Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Sat, 27 Apr 2019 19:17:18 +0200 Subject: [PATCH] =?UTF-8?q?Inicia=20tentar=20corre=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/legacy/migracao.py | 26 +++++++++++++++++++++ sapl/legacy/scripts/restaura_da_producao.sh | 2 ++ 2 files changed, 28 insertions(+) diff --git a/sapl/legacy/migracao.py b/sapl/legacy/migracao.py index 4af13137d..aa3d96569 100644 --- a/sapl/legacy/migracao.py +++ b/sapl/legacy/migracao.py @@ -80,3 +80,29 @@ def scrap_sde(url, usuario, senha=None): pk, res.status_code, url_proposicao, num / total)) if res.status_code == 200: salva_conteudo_do_sde(proposicao, res.content) + + +def tenta_correcao(): + from sapl.legacy.migracao_dados import ocorrencias + + gravar_marco('producao', pula_se_ja_existe=True) + migrar_dados() + assert 'fk' not in ocorrencias, "AINDA EXISTEM FKS ORFAS" + gravar_marco() + from IPython import get_ipython + import git + sigla = NOME_BANCO_LEGADO[-3:] + + print(f'cd ~/migracao_sapl/repos/sapl_cm_{sigla}') + get_ipython().run_line_magic( + 'cd', f'~/migracao_sapl/repos/sapl_cm_{sigla}') + get_ipython().system("diff -rq producao dados | grep -v 'Only in dados' | grep -v 'Files producao/sequences.yaml and dados/sequences.yaml differ'") # noqa + get_ipython().system('vimdiff producao/sequences.yaml dados/sequences.yaml') # noqa + + ajustes = Path( + f'/home/mazza/work/consulta_sapls/ajustes_pre_migracao/{sigla}.sql').read_file() # noqa + assert ajustes.count('RESSUSCITADOS') == 1 + consulta_sapl = git.Repo(f'/home/mazza/work/consulta_sapls') + consulta_sapl.git.add( + f'/home/mazza/work/consulta_sapls/ajustes_pre_migracao/{sigla}.sql') + consulta_sapl.index.commit(f'Ajusta {sigla} (p migração corretiva)') diff --git a/sapl/legacy/scripts/restaura_da_producao.sh b/sapl/legacy/scripts/restaura_da_producao.sh index ea93544da..d0c6f8031 100755 --- a/sapl/legacy/scripts/restaura_da_producao.sh +++ b/sapl/legacy/scripts/restaura_da_producao.sh @@ -8,3 +8,5 @@ sudo -u postgres psql -c "CREATE DATABASE $1 WITH OWNER = sapl ENCODING = 'UTF8' sudo -u postgres pg_restore -d $1 -U postgres "$HOME/migracao_sapl/dumps_producao/$1.prod" echo "... restaurado" +DATABASE_NAME=$1 ./manage.py shell_plus --settings=sapl.legacy_migration_settings +