mirror of https://github.com/interlegis/sapl.git
Browse Source
* Retira senhas hardcoded Signed-off-by: Luciano Almeida <lucianoalmeida@interlegis.leg.br> * Arruma ajuste de proposição Signed-off-by: Luciano Almeida <lucianoalmeida@interlegis.leg.br>pull/1490/head
Luciano Henrique Nunes de Almeida
7 years ago
committed by
Edward
5 changed files with 54 additions and 18 deletions
@ -1,20 +1,33 @@ |
|||
#!/bin/bash |
|||
|
|||
# rodar esse script na raiz do projeto |
|||
if [ $# -eq 3 ]; then |
|||
DIR=~/logs_migracao |
|||
mkdir -p $DIR |
|||
|
|||
DIR=~/logs_migracao |
|||
mkdir -p $DIR |
|||
LOG="$DIR/$1.migracao.log" |
|||
rm -f $LOG |
|||
|
|||
LOG="$DIR/$1.migracao.log" |
|||
rm -f $LOG |
|||
echo "########################################" | tee -a $LOG |
|||
echo "MIGRANDO BANCO $1" | tee -a $LOG |
|||
echo "########################################" | tee -a $LOG |
|||
echo >> $LOG |
|||
|
|||
echo "########################################" | tee -a $LOG |
|||
echo "MIGRANDO BANCO $1" | tee -a $LOG |
|||
echo "########################################" | tee -a $LOG |
|||
echo >> $LOG |
|||
echo "--- CRIANDO BACKUP ---" | tee -a $LOG |
|||
echo >> $LOG |
|||
mysql -u $2 -p$3 -e "create database if not exists $1_copy;" && mysqldump -u $2 -p$3 $1 | mysql -u $2 -p$3 $1_copy; |
|||
echo >> $LOG |
|||
|
|||
echo "--- DJANGO MIGRATE ---" | tee -a $LOG |
|||
echo >> $LOG |
|||
DATABASE_NAME=$1 ./manage.py migrate --settings sapl.legacy_migration_settings |
|||
echo >> $LOG |
|||
|
|||
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 "--- 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 |
|||
else |
|||
echo "USO:" |
|||
echo " ./sapl/legacy/scripts/migra_um_db.sh [nome_database] [usuário mysql] [senha mysql]" |
|||
fi; |
|||
|
@ -1,5 +1,11 @@ |
|||
# (Re)cria todos os bancos postgres para migração |
|||
# cria um banco postgres (de mesmo nome) para cada banco mysql cujo nome começa com "sapl_" |
|||
|
|||
mysql -u root -padmin -e 'show databases;' | grep '^sapl_' | xargs -I{} ./recria_um_db_postgres.sh {} |
|||
|
|||
if [ $# -eq 2 ]; then |
|||
parallel --verbose ./recria_um_db_postgres.sh :::: <(mysql -u $1 -p$2 -e 'show databases;' | grep '^sapl_' | grep -v '_copy$') |
|||
else |
|||
echo "USO:" |
|||
echo " ./recria_dbs_postgres.sh [usuário mysql] [senha mysql]" |
|||
fi; |
|||
|
|||
|
@ -1,5 +1,6 @@ |
|||
# (Re)cria um db postgres |
|||
# uso: recria_um_db_postgres <NOME DO BANCO> |
|||
|
|||
echo "Database $1" |
|||
sudo -u postgres psql -c "drop DATABASE if exists $1" |
|||
sudo -u postgres psql -c "CREATE DATABASE $1 WITH OWNER = sapl ENCODING = 'UTF8' TABLESPACE = pg_default LC_COLLATE = 'pt_BR.UTF-8' LC_CTYPE = 'pt_BR.UTF-8' CONNECTION LIMIT = -1 TEMPLATE template0;" |
|||
|
Loading…
Reference in new issue