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

[FIX] SQL : Correction de contraintes d'unicité suite à la migration Oracle => Postgres.

parent 4bd0dfce
Loading
Loading
Loading
Loading
+29 −0
Changes for doc/release-notes/v3.0.1.md: 29 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -80,6 +80,35 @@ where not exists (
      select * from role_privilege where role_id = p2r.role_id and privilege_id = pp.privilege_id
)
;

--
-- Correction de contraintes d'unicité suite à la migration Oracle => Postgres.
--
--select * from pg_indexes where schemaname = 'public' and indexdef ilike '%UNIQUE%HISTO%';
drop index validation_un;
create unique index validation_un_1
  on validation using btree (type_validation_id, these_id, individu_id, histo_destruction) where histo_destruction is not null;
create unique index validation_un_2
  on validation using btree (type_validation_id, these_id, individu_id) where histo_destruction is null;

drop index doctorant_compl_un;
create unique index doctorant_compl_un_1
  on doctorant_compl using btree (persopass, histo_destruction) where histo_destruction is not null;
create unique index doctorant_compl_un_2
  on doctorant_compl using btree (persopass) where histo_destruction is null;

drop index individu_source_code_uniq;
create unique index individu_source_code_uniq_1
  on individu using btree (source_code, histo_destruction) where histo_destruction is not null;
create unique index individu_source_code_uniq_2
  on individu using btree (source_code) where histo_destruction is null;

drop index rapport_validation_un;
create unique index rapport_validation_un_1
  on rapport_validation using btree (type_validation_id, rapport_id, individu_id, histo_destruction) where histo_destruction is not null;
create unique index rapport_validation_un_2
  on rapport_validation using btree (type_validation_id, rapport_id, individu_id) where histo_destruction is null;

```