Browse Source

Reorganiza código de migração

pull/1751/merge
Marcio Mazza 7 years ago
parent
commit
4ef092b19f
  1. 1160
      sapl/legacy/migracao.py
  2. 1155
      sapl/legacy/migracao_dados.py
  3. 2
      sapl/legacy/migracao_documentos.py
  4. 2
      sapl/legacy/migracao_usuarios.py
  5. 6
      sapl/legacy/scripts/migra_um_db.sh
  6. 2
      sapl/legacy/scripts/scrap_original_forms.py
  7. 2
      sapl/legacy/scripts/study.py
  8. 2
      sapl/legacy/scripts/utils.py
  9. 5
      sapl/legacy/test_migracao_dados.py
  10. 2
      sapl/legacy/test_renames.py

1160
sapl/legacy/migracao.py

File diff suppressed because it is too large

1155
sapl/legacy/migracao_dados.py

File diff suppressed because it is too large

2
sapl/legacy/migracao_documentos.py

@ -6,7 +6,7 @@ from glob import glob
import yaml
from sapl.base.models import CasaLegislativa
from sapl.legacy.migracao import exec_legado, warn
from sapl.legacy.migracao_dados import exec_legado, warn
from sapl.materia.models import (DocumentoAcessorio, MateriaLegislativa,
Proposicao)
from sapl.norma.models import NormaJuridica

2
sapl/legacy/migracao_usuarios.py

@ -44,7 +44,7 @@ def decode_nome(nome):
return nome
def migra_usuarios():
def migrar_usuarios():
"""
o arquivo media/usuarios.yaml e importa os usuários nele listados,
com senhas e perfis.

6
sapl/legacy/scripts/migra_um_db.sh

@ -4,7 +4,7 @@
if [ $# -ge 2 ]; then
# proteje pasta com dumps de alterações acidentais
chmod -R -w ~/sapl_dumps
chmod -R -w ~/migracao_sapl/sapl_dumps
DATE=$(date +%Y-%m-%d)
DIR=~/${DATE}_logs_migracao
@ -21,11 +21,11 @@ if [ $# -ge 2 ]; then
if [ $3 ]; then
# se há senha do mysql
mysql -u $2 -p "$3" -N -s -e "DROP DATABASE IF EXISTS $1; CREATE DATABASE $1;"
mysql -u $2 -p "$3" < ~/sapl_dumps/$1.sql
mysql -u $2 -p "$3" < ~/migracao_sapl/sapl_dumps/$1.sql
else
# se não há senha do mysql
mysql -u $2 -N -s -e "DROP DATABASE IF EXISTS $1; CREATE DATABASE $1;"
mysql -u $2 < ~/sapl_dumps/$1.sql
mysql -u $2 < ~/migracao_sapl/sapl_dumps/$1.sql
fi;
echo "O banco legado foi restaurado" |& tee -a $LOG
echo >> $LOG

2
sapl/legacy/scripts/scrap_original_forms.py

@ -10,7 +10,7 @@ from bs4.element import NavigableString, Tag
from django.apps.config import AppConfig
from sapl.crispy_layout_mixin import heads_and_tails
from sapl.legacy.migracao import appconfs, get_renames
from sapl.legacy.migracao_dados import appconfs, get_renames
from sapl.legacy.scripts.utils import getsourcelines
from sapl.utils import listify

2
sapl/legacy/scripts/study.py

@ -1,6 +1,6 @@
from django.apps import apps
from sapl.legacy.migracao import legacy_app
from sapl.legacy.migracao_dados import legacy_app
for model in apps.get_app_config('legacy').get_models():
if 'ind_excluido' in [f.name for f in model._meta.fields]:

2
sapl/legacy/scripts/utils.py

@ -1,7 +1,7 @@
import inspect
from sapl.base.models import Autor
from sapl.legacy.migracao import appconfs
from sapl.legacy.migracao_dados import appconfs
def getsourcelines(model):

5
sapl/legacy/test_migration.py → sapl/legacy/test_migracao_dados.py

@ -1,7 +1,8 @@
from random import shuffle
from .migracao import (_formatar_lista_para_sql, get_autorias_sem_repeticoes,
get_reapontamento_de_autores_repetidos)
from .migracao_dados import (_formatar_lista_para_sql,
get_autorias_sem_repeticoes,
get_reapontamento_de_autores_repetidos)
def test_unifica_autores_repetidos_no_legado():

2
sapl/legacy/test_renames.py

@ -3,7 +3,7 @@ import sapl.materia
import sapl.norma
import sapl.sessao
from .migracao import appconfs, get_renames, legacy_app
from .migracao_dados import appconfs, get_renames, legacy_app
RENAMING_IGNORED_MODELS = [
sapl.comissoes.models.Composicao,

Loading…
Cancel
Save