#!/bin/sh
# Appel : ./script_creation_schemas etudiants
# Resultat: Creation_schemas_etudiants.sql	
FIC=creation_schemas_$1.sql
echo > $FIC
for u in `cat $1` ; do 
 echo "DROP SCHEMA  IF EXISTS $u ;" >> $FIC
 echo "create schema authorization $u;" >> $FIC
 echo "alter user $u set search_path to $u, donnees, public;" >> $FIC 
 echo "grant select  ON ALL TABLES IN SCHEMA donnees to $u, public;" >> $FIC	
 echo "grant references  ON ALL TABLES IN SCHEMA donnees to $u, public;" >> $FIC
done
