Commit 31c1d80e authored by Florian Joriot's avatar Florian Joriot
Browse files

modification des fichiers sql d'initialisation

parent 2ed8f84a
Loading
Loading
Loading
Loading
Loading
+2 −5
Original line number Diff line number Diff line
create table unicaen_mail_mail
create table if not exists unicaen_mail_mail
(
id serial not null constraint umail_pkey primary key,
date_envoi timestamp not null,
@@ -11,7 +11,4 @@ create table unicaen_mail_mail
log text
);

create unique index ummail_id_uindex on unicaen_mail_mail (id);


create unique index if not exists ummail_id_uindex on unicaen_mail_mail (id);
 No newline at end of file
+37 −6
Original line number Diff line number Diff line
-- MAIL

INSERT INTO unicaen_privilege_categorie (id ,code, libelle, ordre, namespace) VALUES (next_val('unicaen_privilege_categorie_id_seq'), 'mail', 'UnicaenMail - Gestion des mails', 9000, 'UnicaenMail\Provider\Privilege');
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'mail_index', 'Affichage de l''index', 10);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'mail_afficher', 'Afficher un mail', 20);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'mail_reenvoi', 'Ré-envoi d''un mail', 30);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'mail_supprimer', 'Suppression d''un mail', 40);
INSERT INTO unicaen_privilege_privilege (id, categorie_id, code, libelle, ordre) VALUES (next_val('unicaen_privilege_privilege_id_seq'), current_val('unicaen_privilege_categorie_id_seq'), 'mail_test', 'Envoi d''un mail de test', 100);
 No newline at end of file
INSERT INTO UNICAEN_PRIVILEGE_CATEGORIE (
        CODE,
        LIBELLE,
        NAMESPACE,
        ORDRE)
    values
    ('mail', 'UnicaenMail - Gestion des mails', 'UnicaenMail\Provider\Privilege', 1051)
    ON CONFLICT (CODE) DO
    UPDATE SET
        LIBELLE=excluded.LIBELLE,
        NAMESPACE=excluded.NAMESPACE,
        ORDRE=excluded.ORDRE;

WITH d(code, lib, ordre) AS (
    SELECT 'mail_index', 'Affichage de l''index', 1 UNION
    SELECT 'mail_afficher', 'Afficher un mail', 2 UNION
    SELECT 'mail_reenvoi', 'Ré-envoi d''un mail', 30 UNION
    SELECT 'mail_supprimer', 'Suppression d''un mail', 4 UNION
    SELECT 'mail_test', 'Envoi d''un mail de test', 5
)
INSERT INTO unicaen_privilege_privilege(CATEGORIE_ID, CODE, LIBELLE, ORDRE)
    SELECT cp.id, d.code, d.lib, d.ordre
    FROM d
    JOIN unicaen_privilege_categorie cp ON cp.CODE = 'mail'
    ON CONFLICT (CATEGORIE_ID, CODE) DO
    UPDATE SET
        LIBELLE=excluded.LIBELLE,
        ORDRE=excluded.ORDRE;

insert into unicaen_privilege_privilege_role_linker
    (role_id, privilege_id)
    (select role.id, privilege.id from unicaen_utilisateur_role role,
        unicaen_privilege_privilege privilege
    join unicaen_privilege_categorie cp on privilege.categorie_id = cp.id
    where role.role_id = 'Admin_tech'
    and cp.code in('mail'))
    on conflict do nothing;
 No newline at end of file