Skip to content

Commit

Permalink
[SQL] Fix Primary key table proprietaire
Browse files Browse the repository at this point in the history
Il arrive que dans un dépratement pour une division, un proprietaire apparaisse plusieurs fois.
La contrainte d'unicité est donc caduque pour le cahmps `proprietaire` de la table `proprietaire`.

je propose d'ajouter une clé primaire de type serial et un index sur le champs proprietaire.

Funded by [Établissement Public Foncier Hauts De France](https://epf-hdf.fr/)
  • Loading branch information
rldhont committed Oct 6, 2023
1 parent d774c65 commit 0ac83a3
Show file tree
Hide file tree
Showing 17 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2012/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2013/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2014/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2015/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2016/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2017/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2018/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2019/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2020/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2021/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2022/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/2023/majic3_formatage_donnees.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,7 @@ CREATE INDEX sufexoneration_suf_idx ON sufexoneration (suf);
CREATE INDEX idx_proprietaire_ccocom ON proprietaire (ccocom);
CREATE INDEX idx_commune_ccocom ON commune (ccocom);
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
CREATE INDEX idx_local00_parcelle ON local00 (parcelle);
CREATE INDEX idx_local00_voie ON local00 (voie);
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/commun_create_metier.sql
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ CREATE TABLE pevdependances (
);

CREATE TABLE proprietaire (
id serial NOT NULL,
proprietaire text,
annee text,
ccodep text,
Expand Down
2 changes: 1 addition & 1 deletion cadastre/scripts/plugin/commun_creation_contraintes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ALTER TABLE [PREFIXE]pevprincipale ADD CONSTRAINT pevprincipale_pk PRIMARY KEY
ALTER TABLE [PREFIXE]pevprofessionnelle ADD CONSTRAINT pevprofessionnelle_pk PRIMARY KEY (pevprofessionnelle);
ALTER TABLE [PREFIXE]pevlissage ADD CONSTRAINT pevlissage_pk PRIMARY KEY (pevlissage);
ALTER TABLE [PREFIXE]pevdependances ADD CONSTRAINT pevdependances_pk PRIMARY KEY (pevdependances);
ALTER TABLE [PREFIXE]proprietaire ADD CONSTRAINT proprietaire_pk PRIMARY KEY (proprietaire);
ALTER TABLE [PREFIXE]proprietaire ADD CONSTRAINT proprietaire_pk PRIMARY KEY (id);
DELETE FROM [PREFIXE]comptecommunal WHERE comptecommunal IS NULL;
ALTER TABLE [PREFIXE]comptecommunal ADD CONSTRAINT comptecommunal_pk PRIMARY KEY (comptecommunal);
ALTER TABLE [PREFIXE]pdl ADD CONSTRAINT pdl_pk PRIMARY KEY (pdl);
Expand Down
3 changes: 2 additions & 1 deletion cadastre/scripts/plugin/edigeo_create_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ DROP INDEX IF EXISTS idx_commune_majic_ccocom;
CREATE INDEX idx_commune_majic_ccocom ON commune_majic (ccocom);
DROP INDEX IF EXISTS idx_proprietaire_ccodro;
CREATE INDEX idx_proprietaire_ccodro ON proprietaire (ccodro);
DROP INDEX IF EXISTS idx_proprietaire_proprietaire;
CREATE INDEX idx_proprietaire_proprietaire ON proprietaire (proprietaire);
DROP INDEX IF EXISTS idx_proprietaire_comptecommunal;
CREATE INDEX idx_proprietaire_comptecommunal ON proprietaire (comptecommunal);
DROP INDEX IF EXISTS idx_local00_parcelle;
Expand All @@ -69,4 +71,3 @@ DROP INDEX IF EXISTS idx_parcelle_voie;
CREATE INDEX idx_parcelle_voie ON parcelle (voie);
DROP INDEX IF EXISTS idx_parcelle_comptecommunal;
CREATE INDEX idx_parcelle_comptecommunal ON parcelle (comptecommunal);

1 change: 1 addition & 0 deletions cadastre/scripts/plugin/edigeo_drop_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ DROP INDEX IF EXISTS idx_proprietaire_ccocom;
DROP INDEX IF EXISTS idx_commune_ccocom;
DROP INDEX IF EXISTS idx_commune_majic_ccocom;
DROP INDEX IF EXISTS idx_proprietaire_ccodro;
DROP INDEX IF EXISTS idx_proprietaire_proprietaire;
DROP INDEX IF EXISTS idx_proprietaire_comptecommunal;
DROP INDEX IF EXISTS idx_local00_parcelle;
DROP INDEX IF EXISTS idx_local00_voie;
Expand Down
1 change: 1 addition & 0 deletions cadastre/scripts/plugin/majic3_drop_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ DROP INDEX IF EXISTS idx_proprietaire_ccocom;
DROP INDEX IF EXISTS idx_commune_ccocom;
DROP INDEX IF EXISTS idx_majic_commune_ccocom;
DROP INDEX IF EXISTS idx_proprietaire_ccodro;
DROP INDEX IF EXISTS idx_proprietaire_proprietaire;
DROP INDEX IF EXISTS idx_proprietaire_comptecommunal;
DROP INDEX IF EXISTS idx_local00_parcelle;
DROP INDEX IF EXISTS idx_local00_voie;
Expand Down

0 comments on commit 0ac83a3

Please sign in to comment.