Commit e62e599a authored by Alice Salsé's avatar Alice Salsé
Browse files

🔨 build functions

parent 62826e43
#!/bin/bash
# CONSTRUCTION DU SCHEMA DE BASE DE DONNEES
#Including .ini file
. ../database.ini
schemaname=$1
export PGPASSWORD=${password}
echo Creation du schema $schemaname sur la base ${dbname} sur ${host} ${port}
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/create_schema.sql
echo Creation des listes de valeurs
python python/import_value_list.py $schemaname
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -f sql/-vl_copy_tmp.sql
for fichier in ../config/sql/$schemaname/vl_add*.sql
do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -f $fichier
done
echo Creation des tables réseau
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/network/create_table.sql
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -c "TRUNCATE ${schemaname}.pipe_default_node RESTART IDENTITY; TRUNCATE ${schemaname}.default_value RESTART IDENTITY;"
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -c "\copy ${schemaname}.pipe_default_node FROM '../config/csv/${schemaname}/pipe_default_node.csv' WITH DELIMITER ';' ESCAPE'\' CSV HEADER;"
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -c "\copy ${schemaname}.default_value FROM '../config/csv/${schemaname}/default_value.csv' WITH DELIMITER ';' ESCAPE'\' CSV HEADER;"
echo Creation des tables
python python/create_table.py $schemaname
echo Installation des configurations spécifiques
for fichier in ../config/sql/*.sql ../config/sql/$schemaname/add*.sql
do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -f $fichier
done
echo Grant roles
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/grant_tables_roles.sql
rm $fichier sql/-vl_copy_tmp.sql
......@@ -3,6 +3,7 @@
#Including .ini file
. ../database.ini
schemaname=$1
schematype=$2
export PGPASSWORD=${password}
echo Creation du schema $schemaname sur la base ${dbname} sur ${host} ${port}
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/create_schema.sql
......@@ -13,6 +14,14 @@ for fichier in ../config/sql/$schemaname/vl_add*.sql
do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -f $fichier
done
if [ $schematype = "network" ]
then
echo Creation des tables réseau
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/network/create_table.sql
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -c "TRUNCATE ${schemaname}.pipe_default_node RESTART IDENTITY; TRUNCATE ${schemaname}.default_value RESTART IDENTITY;"
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -c "\copy ${schemaname}.pipe_default_node FROM '../config/csv/${schemaname}/pipe_default_node.csv' WITH DELIMITER ';' ESCAPE'\' CSV HEADER;"
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -c "\copy ${schemaname}.default_value FROM '../config/csv/${schemaname}/default_value.csv' WITH DELIMITER ';' ESCAPE'\' CSV HEADER;"
fi
echo Creation des tables
python python/create_table.py $schemaname
echo Installation des configurations spécifiques
......@@ -21,5 +30,5 @@ do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -f $fichier
done
echo Grant roles
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/grant_tables_roles.sql
rm sql/-vl_copy_tmp.sql
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -v schematype=${schematype} -f sql/grant_tables_roles.sql
rm $fichier sql/-vl_copy_tmp.sql
......@@ -4,9 +4,10 @@
. ../database.ini
schemaname=$1
schematype=$2
subtype=${3:-null}
export PGPASSWORD=${password}
echo Installation des fonctionnalités pour le schema ${schemaname} de la base ${dbname} sur ${host} ${port}
for fichier in sql/all/view*.sql sql/all/function*.sql sql/$schematype/function*.sql sql/$schematype/constraints*.sql sql/all/trigger*.sql sql/$schematype/trigger*.sql sql/$schematype/create_view*.sql
echo Installation des fonctionnalités réseau pour le schema ${schemaname} de la base ${dbname} sur ${host} ${port}
for fichier in sql/all/view*.sql sql/all/function*.sql sql/$schematype/function*.sql sql/${schematype}/${subtype}/function*.sql sql/$schematype/constraints*.sql sql/${schematype}/${subtype}/constraints*.sql sql/all/trigger*.sql sql/$schematype/trigger*.sql sql/${schematype}/${subtype}/trigger*.sql sql/$schematype/create_view*.sql
do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f $fichier
done
......@@ -14,4 +15,4 @@ done
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/create_index.sql
python python/qgs_field_definition.py $schemaname
echo Grant roles
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} schematype=${schematype} -f sql/grant_tables_roles.sql
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -v schematype=${schematype} -f sql/grant_tables_roles.sql
#!/bin/bash
# CREATION DES FONCTIONNALITES DU SCHEMA DE BASE DE DONNEES
#Including .ini file
. ../database.ini
schemaname=$1
networktype=$2
export PGPASSWORD=${password}
echo Installation des fonctionnalités réseau pour le schema ${schemaname} de la base ${dbname} sur ${host} ${port}
for fichier in sql/all/view*.sql sql/network/function*.sql sql/all/function*.sql sql/network/$networktype/function*.sql sql/network/$networktype/constraints*.sql sql/all/trigger*.sql sql/network/trigger*.sql sql/network/$networktype/trigger*.sql
do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f $fichier
done
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/network/create_view.sql
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/create_index.sql
python python/qgs_field_definition.py $schemaname
echo Grant roles
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} schematype=network -f sql/grant_tables_roles.sql
......@@ -3,6 +3,7 @@
#Including .ini file
. ../database.ini
schemaname=$1
schematype=$2
export PGPASSWORD=${password}
echo Installation des vues spécifiques de la base ${dbname} sur ${host} ${port}
for fichier in ../config/sql/$schemaname/view*.sql ../config/sql/$schemaname/vm*.sql
......@@ -10,4 +11,4 @@ do
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -f $fichier
done
echo Grant roles
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -f sql/grant_tables_roles.sql
psql -h ${host} -d ${dbname} -U ${user} -p ${port} -b -q -v schemaname=${schemaname} -v schematype=${schematype} -f sql/grant_tables_roles.sql
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment