Commit a3c00375 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Déplacement de SQL pour la v10.2.0

parent 3b9d1dbb
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
# Version 10.1.1

## 1. Sur le serveur d'application

- Placez-vous dans le répertoire de l'application puis lancez la commande suivante
  pour installer la nouvelle version :

  ```bash
  git fetch --tags && git checkout --force 10.1.1 && bash ./install.sh
  ```

## 2. Dans la base de données

Exécutez dans l'ordre les scripts SQL présents dans le répertoire correspondant à la présente version.

>>>>>>>>>> A DEPLACER DANS UN .SQL :

create or replace function privilege__grant_privileges_to_profiles(categorycode character varying, privilegecodes character varying[], profileroleids character varying[]) returns void
    language plpgsql
as
$$declare
    v_priv_code varchar;
    v_priv unicaen_privilege_privilege;
    v_prof_role_id varchar;
    v_prof profil;
BEGIN
    foreach v_priv_code in ARRAY privilegecodes loop
            if not exists (select from unicaen_privilege_privilege where code = v_priv_code) then
                raise warning '[WARN] Role spécifié introuvable avec le code suivant : %', v_priv_code;
            end if;
            foreach v_prof_role_id in ARRAY profileroleids loop
                    if not exists (select from profil where role_id = v_prof_role_id) then
                        raise warning '[WARN] Profil introuvable avec le role_id suivant %', v_priv_code;
                    end if;
                    insert into profil_privilege (privilege_id, profil_id)
                    select p.id as privilege_id, profil.id as profil_id
                    from profil
                             join unicaen_privilege_categorie cp on cp.code = categoryCode
                             join unicaen_privilege_privilege p on p.categorie_id = cp.id and p.code = v_priv_code
                    where profil.role_id = v_prof_role_id
                    on conflict do nothing;
                end loop;
        end loop;
    perform privilege__update_role_privilege();
END;
$$;

+33 −0
Original line number Diff line number Diff line
@@ -8,3 +8,36 @@ alter table soutenance_justificatif
    add constraint justificatif_fichier_these_fk
        foreign key (fichier_these_id) references fichier_these
            on delete cascade;



create or replace function privilege__grant_privileges_to_profiles(categorycode character varying, privilegecodes character varying[], profileroleids character varying[]) returns void
    language plpgsql
as
$$declare
    v_priv_code varchar;
    v_priv unicaen_privilege_privilege;
    v_prof_role_id varchar;
    v_prof profil;
BEGIN
    foreach v_priv_code in ARRAY privilegecodes loop
            if not exists (select from unicaen_privilege_privilege where code = v_priv_code) then
                raise warning '[WARN] Role spécifié introuvable avec le code suivant : %', v_priv_code;
            end if;
            foreach v_prof_role_id in ARRAY profileroleids loop
                    if not exists (select from profil where role_id = v_prof_role_id) then
                        raise warning '[WARN] Profil introuvable avec le role_id suivant %', v_priv_code;
                    end if;
                    insert into profil_privilege (privilege_id, profil_id)
                    select p.id as privilege_id, profil.id as profil_id
                    from profil
                             join unicaen_privilege_categorie cp on cp.code = categoryCode
                             join unicaen_privilege_privilege p on p.categorie_id = cp.id and p.code = v_priv_code
                    where profil.role_id = v_prof_role_id
                    on conflict do nothing;
                end loop;
        end loop;
    perform privilege__update_role_privilege();
END;
$$;