/[openfoncier]/trunk/data/pgsql/v3.2.0-dev.sql
ViewVC logotype

Contents of /trunk/data/pgsql/v3.2.0-dev.sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1562 - (show annotations)
Tue Mar 26 16:25:30 2013 UTC (11 years, 10 months ago) by nhaye
File size: 137355 byte(s)
Annulation des 2 précédentes modif
Ajout d'un script de mise à jour reprenant ces modifs

1 INSERT INTO nature VALUES ('DD', 'Dépôt de dossier DAT');
2 INSERT INTO nature VALUES ('DO', 'Demande d''ouverture ERP DAT');
3 INSERT INTO nature VALUES ('AD', 'Annulation de la demande');
4 INSERT INTO nature VALUES ('DA', 'Demande PC ratachée DAACT');
5 ALTER TABLE dossier ADD COLUMN erp boolean;
6 UPDATE action SET regle_avis = 'avis_decision' WHERE libelle = 'accepter un dossier';
7
8 --
9 -- Ajout de table: avis_consultation_tmp;
10 --
11
12
13 CREATE TABLE avis_consultation_tmp (
14 avis character varying(2) NOT NULL,
15 libelle character varying(30) NOT NULL,
16 typeavis character(1) DEFAULT ''::bpchar NOT NULL,
17 sitadel character(1) DEFAULT ''::bpchar NOT NULL,
18 sitadel_motif character(1) DEFAULT ''::bpchar NOT NULL
19 );
20
21
22 --
23 -- Data for Name: avis_consultation_tmp;
24 --
25
26 INSERT INTO avis_consultation_tmp VALUES ('D', 'Defavorable', 'D', '6', ' ');
27 INSERT INTO avis_consultation_tmp VALUES ('F', 'Favorable', 'F', '4', ' ');
28 INSERT INTO avis_consultation_tmp VALUES ('F1', 'Favorable avec Reserve', 'F', '4', ' ');
29 INSERT INTO avis_consultation_tmp VALUES ('T', 'Tacite', 'F', '2', ' ');
30 INSERT INTO avis_consultation_tmp VALUES ('A', 'Autre', ' ', '7', ' ');
31
32
33 --
34 -- Ajout de la table 'service_categorie'
35 --
36 CREATE TABLE service_categorie (
37 service_categorie integer,
38 libelle varchar(70) NOT NULL default ''
39 );
40
41 ALTER TABLE ONLY service_categorie
42 ADD CONSTRAINT service_categorie_pkey PRIMARY KEY (service_categorie);
43
44 CREATE SEQUENCE service_categorie_seq
45 INCREMENT 1
46 MINVALUE 1
47 MAXVALUE 9223372036854775807
48 START 1
49 CACHE 1;
50
51 --
52 -- Modification de la table 'service' et des clés étangères
53 --
54 ALTER TABLE consultation DROP CONSTRAINT consultation_service_fkey;
55 ALTER TABLE service DROP CONSTRAINT service_pkey;
56
57 ALTER TABLE consultation RENAME COLUMN service TO service_old;
58 ALTER TABLE service RENAME COLUMN service TO service_old;
59
60 CREATE SEQUENCE service_seq
61 START WITH 1
62 INCREMENT BY 1
63 NO MAXVALUE
64 NO MINVALUE
65 CACHE 1;
66
67 ALTER TABLE service ADD COLUMN service integer NOT NULL DEFAULT nextval('service_seq'::regclass);
68 ALTER TABLE consultation ADD COLUMN service integer;
69
70 UPDATE consultation SET service=(select service.service from service where service_old=service.service_old);
71
72 ALTER TABLE service ADD COLUMN consultation_papier boolean;
73 ALTER TABLE service ADD COLUMN notification_email boolean;
74 ALTER TABLE service ADD COLUMN om_validite_debut date;
75 ALTER TABLE service ADD COLUMN om_validite_fin date;
76 ALTER TABLE service ADD COLUMN type_consultation varchar(70) NOT NULL DEFAULT 'avec_avis_attendu';
77
78 ALTER TABLE service RENAME COLUMN service_old TO abrege;
79 ALTER TABLE consultation DROP COLUMN service_old;
80
81 ALTER TABLE ONLY service
82 ADD CONSTRAINT service_pkey PRIMARY KEY (service);
83
84 ALTER TABLE ONLY consultation
85 ADD CONSTRAINT consultation_service_fkey FOREIGN KEY (service) REFERENCES service(service);
86
87 ALTER SEQUENCE service_seq OWNED BY service.service;
88
89 ALTER TABLE service ALTER COLUMN service DROP DEFAULT;
90
91 --
92 -- Ajout de la table 'lien_service_service_categorie'
93 --
94
95 CREATE TABLE lien_service_service_categorie (
96 lien_service_service_categorie integer,
97 service_categorie integer,
98 service integer
99 );
100
101 ALTER TABLE ONLY lien_service_service_categorie
102 ADD CONSTRAINT lien_service_service_categorie_pkey PRIMARY KEY (lien_service_service_categorie);
103 ALTER TABLE ONLY lien_service_service_categorie
104 ADD CONSTRAINT lien_service_service_categorie_service_categorie_fkey FOREIGN KEY (service_categorie) REFERENCES service_categorie(service_categorie);
105 ALTER TABLE ONLY lien_service_service_categorie
106 ADD CONSTRAINT lien_service_service_categorie_service_fkey FOREIGN KEY (service) REFERENCES service(service);
107
108 CREATE SEQUENCE lien_service_service_categorie_seq
109 INCREMENT 1
110 MINVALUE 1
111 MAXVALUE 9223372036854775807
112 START 1
113 CACHE 1;
114
115 --
116 -- Ajout de la table 'lien_service_utilisateur'
117 --
118
119 CREATE TABLE lien_service_om_utilisateur (
120 lien_service_om_utilisateur integer,
121 om_utilisateur bigint,
122 service integer
123 );
124
125 ALTER TABLE ONLY lien_service_om_utilisateur
126 ADD CONSTRAINT lien_service_om_utilisateur_pkey PRIMARY KEY (lien_service_om_utilisateur);
127 ALTER TABLE ONLY lien_service_om_utilisateur
128 ADD CONSTRAINT lien_service_om_utilisateur_om_utilisateur_fkey FOREIGN KEY (om_utilisateur) REFERENCES om_utilisateur(om_utilisateur);
129 ALTER TABLE ONLY lien_service_om_utilisateur
130 ADD CONSTRAINT lien_service_om_utilisateur_service_fkey FOREIGN KEY (service) REFERENCES service(service);
131
132 CREATE SEQUENCE lien_service_om_utilisateur_seq
133 INCREMENT 1
134 MINVALUE 1
135 MAXVALUE 9223372036854775807
136 START 1
137 CACHE 1;
138
139 --
140 -- Ajout des tables 'avis_consultation' et 'avis_decision'
141 --
142
143 CREATE TABLE avis_decision (
144 avis_old character varying(2) NOT NULL,
145 libelle character varying(30) NOT NULL,
146 typeavis character(1) DEFAULT ''::bpchar NOT NULL,
147 sitadel character(1) DEFAULT ''::bpchar NOT NULL,
148 sitadel_motif character(1) DEFAULT ''::bpchar NOT NULL
149 );
150
151 CREATE SEQUENCE avis_decision_seq
152 INCREMENT 1
153 MINVALUE 1
154 MAXVALUE 9223372036854775807
155 START 1
156 CACHE 1;
157
158 CREATE TABLE avis_consultation (
159 avis_old character varying(2) NOT NULL,
160 libelle character varying(30) NOT NULL,
161 abrege character varying(10),
162 om_validite_debut date,
163 om_validite_fin date
164 );
165
166 CREATE SEQUENCE avis_consultation_seq
167 INCREMENT 1
168 MINVALUE 1
169 MAXVALUE 9223372036854775807
170 START 1
171 CACHE 1;
172
173 ALTER TABLE avis_decision ADD COLUMN avis_decision integer NOT NULL DEFAULT nextval('avis_decision_seq'::regclass);
174 INSERT INTO avis_decision(avis_old, libelle, typeavis, sitadel, sitadel_motif) SELECT avis, libelle, typeavis, sitadel, sitadel_motif
175 FROM avis;
176
177 ALTER TABLE avis_consultation ADD COLUMN avis_consultation integer NOT NULL DEFAULT nextval('avis_consultation_seq'::regclass);
178 INSERT INTO avis_consultation(avis_old, libelle) SELECT avis, libelle
179 FROM avis_consultation_tmp;
180
181
182 ALTER TABLE ONLY avis_decision
183 ADD CONSTRAINT avis_decision_pkey PRIMARY KEY (avis_decision);
184 ALTER TABLE ONLY avis_consultation
185 ADD CONSTRAINT avis_consultation_pkey PRIMARY KEY (avis_consultation);
186 ALTER SEQUENCE avis_consultation_seq OWNED BY avis_consultation.avis_consultation;
187 ALTER SEQUENCE avis_decision_seq OWNED BY avis_decision.avis_decision;
188 ALTER TABLE avis_decision ALTER COLUMN avis_decision DROP DEFAULT;
189 ALTER TABLE avis_consultation ALTER COLUMN avis_consultation DROP DEFAULT;
190
191 -- Changement des clés étrangères pour 'avis'
192 ALTER TABLE consultation DROP CONSTRAINT consultation_avis_fkey;
193 ALTER TABLE evenement DROP CONSTRAINT evenement_avis_fkey;
194 ALTER TABLE instruction DROP CONSTRAINT instruction_avis_fkey;
195 ALTER TABLE dossier DROP CONSTRAINT dossier_avis_fkey;
196
197 ALTER TABLE consultation ADD COLUMN avis_consultation integer;
198 ALTER TABLE evenement ADD COLUMN avis_decision integer;
199 ALTER TABLE instruction ADD COLUMN avis_decision integer;
200 ALTER TABLE dossier ADD COLUMN avis_decision integer;
201
202
203
204
205
206 UPDATE consultation SET avis_consultation=(select avis_consultation.avis_consultation from avis_consultation where avis=avis_consultation.avis_old);
207
208 --
209 -- Modification de la table 'consultation'
210 --
211 ALTER TABLE consultation ADD COLUMN date_reception date;
212 ALTER TABLE consultation ADD COLUMN motivation text DEFAULT '';
213 ALTER TABLE consultation ADD COLUMN fichier character varying(100);
214 ALTER TABLE consultation ADD COLUMN lu boolean;
215
216
217
218 UPDATE evenement SET avis_decision=(select avis_decision.avis_decision from avis_decision where avis=avis_decision.avis_old);
219 UPDATE instruction SET avis_decision=(select avis_decision.avis_decision from avis_decision where avis=avis_decision.avis_old);
220 UPDATE dossier SET avis_decision=(select avis_decision.avis_decision from avis_decision where avis=avis_decision.avis_old);
221
222 ALTER TABLE consultation DROP COLUMN avis;
223 ALTER TABLE evenement DROP COLUMN avis;
224 ALTER TABLE instruction DROP COLUMN avis;
225 ALTER TABLE dossier DROP COLUMN avis;
226
227 ALTER TABLE ONLY consultation
228 ADD CONSTRAINT consultation_avis_consultation_fkey FOREIGN KEY (avis_consultation) REFERENCES avis_consultation(avis_consultation);
229 ALTER TABLE ONLY evenement
230 ADD CONSTRAINT evenement_avis_decision_fkey FOREIGN KEY (avis_decision) REFERENCES avis_decision(avis_decision);
231 ALTER TABLE ONLY instruction
232 ADD CONSTRAINT instruction_avis_decision_fkey FOREIGN KEY (avis_decision) REFERENCES avis_decision(avis_decision);
233 ALTER TABLE ONLY dossier
234 ADD CONSTRAINT dossier_avis_decision_fkey FOREIGN KEY (avis_decision) REFERENCES avis_decision(avis_decision);
235 ALTER TABLE avis_decision DROP COLUMN avis_old;
236 ALTER TABLE avis_consultation DROP COLUMN avis_old;
237 DROP TABLE avis;
238 DROP TABLE avis_consultation_tmp;
239
240 --
241 -- Ajout des droits sur les nouvelles tables
242 --
243 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'service_categorie', '4');
244 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_decision', '4');
245 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_consultation', '4');
246 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_service_categorie', '4');
247
248 ALTER TABLE consultation ALTER service SET NOT NULL;
249 ALTER TABLE dossier ADD COLUMN enjeu_erp boolean;
250 ALTER TABLE dossier ADD COLUMN enjeu_urba boolean;
251
252 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_mes_retours', 4);
253 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_tous_retours', 4);
254 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'PC', 2); -- droit d'instructeur
255 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_mes_retours', 2); -- droit d'instructeur
256 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_tous_retours', 2); -- droit d'instructeur
257 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dossier_message_consulter', 2); -- droit d'instructeur
258 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dossier_message_modifier', 2); -- droit d'instructeur
259 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dossier_message_tab', 2); -- droit d'instructeur
260 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dossier', 2); -- droit d'instructeur
261 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dashboard', 2); -- droit d'instructeur
262 INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'menu_instruction', 2); -- droit d'instructeur
263
264 --
265 -- Modification de la structure des instructeurs
266 --
267 CREATE SEQUENCE direction_seq
268 START WITH 1
269 INCREMENT BY 1
270 NO MINVALUE
271 NO MAXVALUE
272 CACHE 1;
273
274 CREATE TABLE direction (
275 direction integer NOT NULL,
276 code character varying(20) NOT NULL,
277 libelle character varying(100) NOT NULL,
278 description text,
279 chef character varying(100) NOT NULL,
280 om_validite_debut date,
281 om_validite_fin date,
282 PRIMARY KEY (direction)
283 );
284
285 INSERT INTO direction VALUES (nextval('direction_seq'::regclass),'ADS', 'Direction ADS', 'Direction des autorisations des droits du sol', 'Mme Dupont', NULL, NULL);
286
287 CREATE SEQUENCE division_seq
288 START WITH 1
289 INCREMENT BY 1
290 NO MINVALUE
291 NO MAXVALUE
292 CACHE 1;
293
294 CREATE TABLE division (
295 division integer NOT NULL,
296 code character varying(20) NOT NULL,
297 libelle character varying(100) NOT NULL,
298 description text,
299 chef character varying(100) NOT NULL,
300 direction integer NOT NULL,
301 om_validite_debut date,
302 om_validite_fin date,
303 PRIMARY KEY (division),
304 FOREIGN KEY ( direction ) REFERENCES direction ( direction )
305 );
306
307 INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1, NULL, NULL);
308
309 CREATE SEQUENCE instructeur_seq
310 START WITH 1
311 INCREMENT BY 1
312 NO MINVALUE
313 NO MAXVALUE
314 CACHE 1;
315
316 CREATE TABLE instructeur (
317 instructeur integer NOT NULL,
318 nom character varying(100) NOT NULL,
319 telephone character varying(14),
320 division integer NOT NULL,
321 om_utilisateur integer,
322 om_validite_debut date,
323 om_validite_fin date,
324 PRIMARY KEY ( instructeur ),
325 FOREIGN KEY ( division ) REFERENCES division ( division ),
326 FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur )
327 );
328
329 -- Insertion des utilisateurs instructeurs dans la table instructeur
330 INSERT INTO instructeur (instructeur,nom,telephone,division,om_utilisateur)
331 (SELECT om_utilisateur,nom,telephone,1,om_utilisateur FROM om_utilisateur WHERE instructeur='Oui');
332 -- Mise a jour de la sequence
333 SELECT setval('instructeur_seq',(SELECT MAX(instructeur) FROM instructeur));
334
335
336 -- Augment le om_parametre.libelle d'avoir 40 characteres
337 ALTER TABLE om_parametre ALTER libelle TYPE character varying(50);
338
339 -- Creation du parametre pour afficher ou non la division dans les dossiers
340 INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'afficher_division','false',1);
341
342 -- Ajout des droits sur les tables d'organisation
343 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'direction', '2');
344 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'division', '2');
345 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'instructeur', '2');
346
347 -- Modification de la clé étrangère dossier -> om_utilisateur par dossier -> instructeur
348 ALTER TABLE dossier DROP CONSTRAINT dossier_instructeur_fkey;
349 ALTER TABLE dossier ADD CONSTRAINT
350 dossier_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur);
351
352 ALTER TABLE dossier ADD COLUMN division integer;
353 ALTER TABLE dossier ADD CONSTRAINT
354 dossier_division_fkey FOREIGN KEY (division) REFERENCES division(division);
355
356 -- Ajout des parametres des liens dans la table om_parametre
357 INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'services_consultes_lien_interne', '',1);
358 INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'services_consultes_lien_externe', '',1);
359 ALTER TABLE om_parametre ALTER COLUMN valeur TYPE text;
360
361
362 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_code_barre', '2');
363
364 --
365 -- Ajout des tables arrondissement, quartier et affectation_automatique
366 --
367 CREATE TABLE arrondissement (
368 arrondissement integer NOT NULL,
369 libelle character varying(3) NOT NULL,
370 code_postal character varying(5) NOT NULL
371 );
372
373 ALTER TABLE ONLY arrondissement
374 ADD CONSTRAINT arrondissement_pkey PRIMARY KEY (arrondissement);
375
376 CREATE SEQUENCE arrondissement_seq
377 INCREMENT 1
378 MINVALUE 1
379 MAXVALUE 9223372036854775807
380 START 1
381 CACHE 1;
382
383 CREATE TABLE quartier (
384 quartier integer NOT NULL,
385 arrondissement integer NOT NULL,
386 code_impots character varying(3) NOT NULL,
387 libelle character varying(40) NOT NULL
388 );
389
390 ALTER TABLE ONLY quartier
391 ADD CONSTRAINT quartier_pkey PRIMARY KEY (quartier);
392 ALTER TABLE ONLY quartier
393 ADD CONSTRAINT quartier_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement);
394
395 CREATE SEQUENCE quartier_seq
396 INCREMENT 1
397 MINVALUE 1
398 MAXVALUE 9223372036854775807
399 START 1
400 CACHE 1;
401
402 CREATE TABLE affectation_automatique (
403 affectation_automatique integer NOT NULL,
404 arrondissement integer,
405 quartier integer ,
406 section varchar(2),
407 instructeur integer NOT NULL
408 );
409
410 ALTER TABLE ONLY affectation_automatique
411 ADD CONSTRAINT affectation_automatique_pkey PRIMARY KEY (affectation_automatique);
412 ALTER TABLE ONLY affectation_automatique
413 ADD CONSTRAINT affectation_automatique_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement);
414 ALTER TABLE ONLY affectation_automatique
415 ADD CONSTRAINT affectation_automatique_quartier_fkey FOREIGN KEY (quartier) REFERENCES quartier(quartier);
416 ALTER TABLE ONLY affectation_automatique
417 ADD CONSTRAINT affectation_automatique_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur);
418
419 CREATE SEQUENCE affectation_automatique_seq
420 INCREMENT 1
421 MINVALUE 1
422 MAXVALUE 9223372036854775807
423 START 1
424 CACHE 1;
425
426 -- Ajout des droits pour le retour des services
427 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_encours', '2');
428
429 -- Suppression des colonnes inutiles dans la table om_utilisateur
430 ALTER TABLE om_utilisateur DROP instructeur;
431
432 ALTER TABLE om_utilisateur DROP telephone;
433
434 -- Ajout des droits sur lien_service_om_utilisateur
435 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_om_utilisateur', '2');
436 -- Ajout des droits pour le retour des services
437 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_passee', '2');
438
439 -- Ajout des droits sur affectation_automatique
440 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'affectation_automatique', '2');
441
442 -- Ajout du droit pour changer l'état (lu/non lu) d'une consultation
443 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_modifier_lu', '2');
444
445 -- Changement de taille du champs parcelle de la table parcelle et terrain
446 ALTER TABLE parcelle ALTER COLUMN parcelle TYPE character varying(20);
447 ALTER TABLE terrain ALTER COLUMN parcelle TYPE character varying(20);
448
449
450 --
451 -- Messages
452 --
453
454 -- create sequence for the message ID generation
455 CREATE SEQUENCE dossier_message_seq
456 START WITH 1
457 INCREMENT BY 1
458 NO MINVALUE
459 NO MAXVALUE
460 CACHE 1;
461
462 -- Create table dossier_message
463 CREATE TABLE dossier_message (
464 dossier_message integer PRIMARY KEY,
465 dossier character varying(20),
466 type character varying(60),
467 emetteur character varying(40),
468 date_emission TIMESTAMP NOT NULL,
469 lu boolean default FALSE,
470 contenu text,
471 FOREIGN KEY ( dossier ) REFERENCES dossier ( dossier )
472 );
473
474 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'menu_suivi', '2');
475
476 -- Droit de l'ajout forcé d'un instructeur
477 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'dossier_modifier_instructeur', '2');
478
479
480 ---
481 --- TABLE : GENRE
482 ---
483 CREATE TABLE genre (
484 genre integer,
485 code character varying(20),
486 libelle character varying(100),
487 description text
488 );
489 ALTER TABLE ONLY genre
490 ADD CONSTRAINT genre_pkey PRIMARY KEY (genre);
491 CREATE SEQUENCE genre_seq
492 INCREMENT 1
493 MINVALUE 1
494 MAXVALUE 9223372036854775807
495 START 1
496 CACHE 1;
497
498
499 ---
500 --- TABLE : GROUPE
501 ---
502 CREATE TABLE groupe (
503 groupe integer,
504 code character varying(20),
505 libelle character varying(100),
506 description text,
507 genre integer NOT NULL
508 );
509 ALTER TABLE ONLY groupe
510 ADD CONSTRAINT groupe_pkey PRIMARY KEY (groupe);
511 ALTER TABLE ONLY groupe
512 ADD CONSTRAINT groupe_genre_fkey FOREIGN KEY (genre) REFERENCES genre(genre);
513 CREATE SEQUENCE groupe_seq
514 INCREMENT 1
515 MINVALUE 1
516 MAXVALUE 9223372036854775807
517 START 1
518 CACHE 1;
519
520
521 ---
522 ---
523 ---
524 CREATE TABLE dossier_autorisation_type (
525 dossier_autorisation_type integer,
526 code character varying(20) not null,
527 libelle character varying(100),
528 description text,
529 confidentiel boolean default FALSE,
530 CONSTRAINT code_unique UNIQUE (code)
531 );
532
533 ALTER TABLE ONLY dossier_autorisation_type
534 ADD CONSTRAINT dossier_autorisation_type_pkey PRIMARY KEY (dossier_autorisation_type);
535
536 CREATE SEQUENCE dossier_autorisation_type_seq
537 INCREMENT 1
538 MINVALUE 1
539 MAXVALUE 9223372036854775807
540 START 1
541 CACHE 1;
542
543 --
544
545 CREATE TABLE dossier_autorisation_type_detaille (
546 dossier_autorisation_type_detaille integer,
547 code character varying(20),
548 libelle character varying(100),
549 description text,
550 dossier_autorisation_type integer NOT NULL
551 );
552
553 ALTER TABLE ONLY dossier_autorisation_type_detaille
554 ADD CONSTRAINT dossier_autorisation_type_detaille_pkey PRIMARY KEY (dossier_autorisation_type_detaille);
555 ALTER TABLE ONLY dossier_autorisation_type_detaille
556 ADD CONSTRAINT dossier_autorisation_type_detaille_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type);
557
558 CREATE SEQUENCE dossier_autorisation_type_detaille_seq
559 INCREMENT 1
560 MINVALUE 1
561 MAXVALUE 9223372036854775807
562 START 1
563 CACHE 1;
564
565 -- Ajout du champs dossier_autorisation_type_detaille dans la table affectation_automatique et de la contrainte FK
566
567 ALTER TABLE affectation_automatique ADD COLUMN dossier_autorisation_type_detaille integer;
568
569 ALTER TABLE ONLY affectation_automatique
570 ADD CONSTRAINT affectation_automatique_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille);
571
572 --
573
574 CREATE TABLE dossier_instruction_type (
575 dossier_instruction_type integer,
576 code character varying(20),
577 libelle character varying(100),
578 description text,
579 dossier_autorisation_type_detaille integer NOT NULL,
580 suffixe boolean default FALSE,
581 cerfa integer,
582 cerfa_lot integer
583 );
584
585 ALTER TABLE ONLY dossier_instruction_type
586 ADD CONSTRAINT dossier_instruction_type_pkey PRIMARY KEY (dossier_instruction_type);
587 ALTER TABLE ONLY dossier_instruction_type
588 ADD CONSTRAINT dossier_instruction_type_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille);
589
590 CREATE SEQUENCE dossier_instruction_type_seq
591 INCREMENT 1
592 MINVALUE 1
593 MAXVALUE 9223372036854775807
594 START 1
595 CACHE 1;
596
597
598 -- Ajout de clé étrangère à la table dossier_autorisation_type
599 ALTER TABLE dossier_autorisation_type ADD COLUMN groupe integer;
600 ALTER TABLE ONLY dossier_autorisation_type
601 ADD CONSTRAINT dossier_autorisation_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe);
602
603 --Demande nature
604
605 CREATE TABLE demande_nature (
606 demande_nature integer,
607 code character varying(20),
608 libelle character varying(100),
609 description text
610 );
611
612 ALTER TABLE ONLY demande_nature
613 ADD CONSTRAINT demande_nature_pkey PRIMARY KEY (demande_nature);
614
615 CREATE SEQUENCE demande_nature_seq
616 INCREMENT 1
617 MINVALUE 1
618 MAXVALUE 9223372036854775807
619 START 1
620 CACHE 1;
621
622 --Demande type
623
624 CREATE TABLE demande_type (
625 demande_type integer,
626 code character varying(20),
627 libelle character varying(100),
628 description text,
629 demande_nature integer,
630 groupe integer,
631 dossier_instruction_type integer,
632 dossier_autorisation_type_detaille integer,
633 contraintes character varying(20),
634 etats_dossier_autorisation_autorises character varying(100),
635 qualification boolean,
636 evenement integer NOT NULL
637 );
638
639 ALTER TABLE ONLY demande_type
640 ADD CONSTRAINT demande_type_pkey PRIMARY KEY (demande_type);
641 ALTER TABLE ONLY demande_type
642 ADD CONSTRAINT demande_type_demande_nature_fkey FOREIGN KEY (demande_nature) REFERENCES demande_nature(demande_nature);
643 ALTER TABLE ONLY demande_type
644 ADD CONSTRAINT demande_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe);
645 ALTER TABLE ONLY demande_type
646 ADD CONSTRAINT demande_type_dossier_instruction_type_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type);
647 ALTER TABLE ONLY demande_type
648 ADD CONSTRAINT demande_type_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille);
649 ALTER TABLE ONLY demande_type
650 ADD CONSTRAINT demande_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement);
651
652 CREATE SEQUENCE demande_type_seq
653 INCREMENT 1
654 MINVALUE 1
655 MAXVALUE 9223372036854775807
656 START 1
657 CACHE 1;
658
659 --
660
661 CREATE TABLE lien_evenement_dossier_autorisation_type (
662 lien_evenement_dossier_autorisation_type integer,
663 evenement integer,
664 dossier_autorisation_type integer
665 );
666
667 ALTER TABLE ONLY lien_evenement_dossier_autorisation_type
668 ADD CONSTRAINT lien_evenement_dossier_autorisation_type_pkey PRIMARY KEY (lien_evenement_dossier_autorisation_type);
669 ALTER TABLE ONLY lien_evenement_dossier_autorisation_type
670 ADD CONSTRAINT lien_evenement_dossier_autorisation_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement);
671 ALTER TABLE ONLY lien_evenement_dossier_autorisation_type
672 ADD CONSTRAINT lien_evenement_dossier_autorisation_type_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type);
673
674 CREATE SEQUENCE lien_evenement_dossier_autorisation_type_seq
675 INCREMENT 1
676 MINVALUE 1
677 MAXVALUE 9223372036854775807
678 START 1
679 CACHE 1;
680
681 --
682
683 CREATE TABLE autorite_competente (
684 autorite_competente integer,
685 code character varying(20),
686 libelle character varying(100),
687 description text
688 );
689
690 ALTER TABLE ONLY autorite_competente
691 ADD CONSTRAINT autorite_competente_pkey PRIMARY KEY (autorite_competente);
692
693 CREATE SEQUENCE autorite_competente_seq
694 INCREMENT 1
695 MINVALUE 1
696 MAXVALUE 9223372036854775807
697 START 1
698 CACHE 1;
699
700 -- Ajout de clé étrangère à la table dossier_autorisation_type
701 ALTER TABLE dossier ADD COLUMN autorite_competente integer;
702 ALTER TABLE ONLY dossier
703 ADD CONSTRAINT dossier_autorite_competente_fkey FOREIGN KEY (autorite_competente) REFERENCES autorite_competente(autorite_competente);
704
705 -- Donnees des tables
706 INSERT INTO dossier_autorisation_type(dossier_autorisation_type, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature;
707 ---INSERT INTO dossier_autorisation_type_detaille(dossier_autorisation_type_detaille, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature;
708
709 -- Table dossier_autorisation
710
711 CREATE TABLE dossier_autorisation (
712 dossier_autorisation character varying(20),
713 dossier_autorisation_type_detaille integer,
714 exercice integer,
715 insee integer,
716 terrain_references_cadastrales character varying(100),
717 terrain_adresse_voie_numero integer,
718 complement character varying(30),
719 terrain_adresse_lieu_dit character varying(30),
720 terrain_adresse_localite character varying(30),
721 terrain_adresse_code_postal character varying(5),
722 terrain_adresse_bp character varying(15),
723 terrain_adresse_cedex character varying(15),
724 terrain_superficie double precision,
725 arrondissement integer,
726 depot_initial date,
727 etat character varying(20),
728 erp_numero_batiment integer,
729 erp_ouvert boolean,
730 erp_date_ouverture date,
731 erp_arrete_decision boolean,
732 erp_date_arrete_decision date,
733 numero_version integer DEFAULT 0
734 );
735
736 ALTER TABLE ONLY dossier_autorisation
737 ADD CONSTRAINT dossier_autorisation_pkey PRIMARY KEY (dossier_autorisation);
738 ALTER TABLE ONLY dossier_autorisation
739 ADD CONSTRAINT dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille);
740 ALTER TABLE ONLY dossier_autorisation
741 ADD CONSTRAINT dossier_autorisation_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement);
742 ALTER TABLE ONLY dossier_autorisation
743 ADD CONSTRAINT dossier_autorisation_etat_fkey FOREIGN KEY (etat) REFERENCES etat(etat);
744
745 CREATE SEQUENCE dossier_autorisation_seq
746 INCREMENT 1
747 MINVALUE 1
748 MAXVALUE 9223372036854775807
749 START 1
750 CACHE 1;
751
752 -- Table Demande
753
754 CREATE TABLE demande (
755 demande integer,
756 dossier_autorisation_type_detaille integer NOT NULL,
757 demande_type integer NOT NULL,
758 dossier_instruction character varying(20),
759 dossier_autorisation character varying(20),
760 date_demande date NOT NULL,
761 terrain_references_cadastrales character varying(100),
762 terrain_adresse_voie_numero integer,
763 complement character varying(30),
764 terrain_adresse_lieu_dit character varying(30),
765 terrain_adresse_localite character varying(30),
766 terrain_adresse_code_postal character varying(5),
767 terrain_adresse_bp character varying(15),
768 terrain_adresse_cedex character varying(15),
769 terrain_superficie double precision,
770 nombre_lots integer,
771 instruction_recepisse integer,
772 arrondissement integer
773 );
774
775 ALTER TABLE ONLY demande
776 ADD CONSTRAINT demande_pkey PRIMARY KEY (demande);
777 ALTER TABLE ONLY demande
778 ADD CONSTRAINT demande_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille);
779 ALTER TABLE ONLY demande
780 ADD CONSTRAINT demande_demande_type_fkey FOREIGN KEY (demande_type) REFERENCES demande_type(demande_type);
781 ALTER TABLE ONLY demande
782 ADD CONSTRAINT demande_dossier_instruction_fkey FOREIGN KEY (dossier_instruction) REFERENCES dossier(dossier);
783 ALTER TABLE ONLY demande
784 ADD CONSTRAINT demande_dossier_autorisation_fkey FOREIGN KEY (dossier_autorisation) REFERENCES dossier_autorisation(dossier_autorisation);
785 ALTER TABLE ONLY demande
786 ADD CONSTRAINT demande_instruction_recepisse_fkey FOREIGN KEY (instruction_recepisse) REFERENCES instruction(instruction);
787 ALTER TABLE ONLY demande
788 ADD CONSTRAINT demande_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement);
789
790 CREATE SEQUENCE demande_seq
791 INCREMENT 1
792 MINVALUE 1
793 MAXVALUE 9223372036854775807
794 START 1
795 CACHE 1;
796
797 -- Table Demandeur
798
799 CREATE TABLE demandeur (
800 demandeur integer,
801 type_demandeur character varying(40),
802 qualite character varying(40),
803 particulier_civilite character varying(10),
804 particulier_nom character varying(40),
805 particulier_prenom character varying(40),
806 particulier_date_naissance date,
807 particulier_commune_naissance character varying(30),
808 particulier_departement_naissance character varying(80),
809 personne_morale_denomination character varying(15),
810 personne_morale_raison_sociale character varying(15),
811 personne_morale_siret character varying(15),
812 personne_morale_categorie_juridique character varying(15),
813 personne_morale_civilite character varying(10),
814 personne_morale_nom character varying(40),
815 personne_morale_prenom character varying(40),
816 numero character varying(5),
817 voie character varying(40),
818 complement character varying(39),
819 lieu_dit character varying(39),
820 localite character varying(30),
821 code_postal character varying(5),
822 bp character varying(5),
823 cedex character varying(5),
824 pays character varying(40),
825 division_territoriale character varying(40),
826 telephone_fixe character varying(14),
827 telephone_mobile character varying(14),
828 indicatif character varying(5),
829 courriel character varying(40),
830 notification boolean,
831 frequent boolean
832 );
833
834 ALTER TABLE ONLY demandeur
835 ADD CONSTRAINT demandeur_pkey PRIMARY KEY (demandeur);
836 ALTER TABLE ONLY demandeur
837 ADD CONSTRAINT demandeur_particulier_civilite_fkey FOREIGN KEY (particulier_civilite) REFERENCES civilite(civilite);
838 ALTER TABLE ONLY demandeur
839 ADD CONSTRAINT demandeur_personne_morale_civilite_fkey FOREIGN KEY (personne_morale_civilite) REFERENCES civilite(civilite);
840
841 CREATE SEQUENCE demandeur_seq
842 INCREMENT 1
843 MINVALUE 1
844 MAXVALUE 9223372036854775807
845 START 1
846 CACHE 1;
847
848 -- Table Lien demande demandeur
849
850 CREATE TABLE lien_demande_demandeur (
851 lien_demande_demandeur integer,
852 petitionnaire_principal boolean,
853 demande integer,
854 demandeur integer
855 );
856
857 ALTER TABLE ONLY lien_demande_demandeur
858 ADD CONSTRAINT lien_demande_demandeur_pkey PRIMARY KEY (lien_demande_demandeur);
859 ALTER TABLE ONLY lien_demande_demandeur
860 ADD CONSTRAINT lien_demande_demandeur_demande_fkey FOREIGN KEY (demande) REFERENCES demande(demande);
861 ALTER TABLE ONLY lien_demande_demandeur
862 ADD CONSTRAINT lien_demande_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur);
863
864 CREATE SEQUENCE lien_demande_demandeur_seq
865 INCREMENT 1
866 MINVALUE 1
867 MAXVALUE 9223372036854775807
868 START 1
869 CACHE 1;
870
871 -- Table lot
872
873 CREATE TABLE lot (
874 lot integer,
875 dossier_instruction character varying(12)
876 );
877
878 ALTER TABLE ONLY lot
879 ADD CONSTRAINT lot_pkey PRIMARY KEY (lot);
880 ALTER TABLE ONLY lot
881 ADD CONSTRAINT lot_dossier_instruction_fkey FOREIGN KEY (dossier_instruction) REFERENCES dossier(dossier);
882
883 CREATE SEQUENCE lot_seq
884 INCREMENT 1
885 MINVALUE 1
886 MAXVALUE 9223372036854775807
887 START 1
888 CACHE 1;
889
890 -- Table lien_lot_demandeur
891
892 CREATE TABLE lien_lot_demandeur (
893 lien_lot_demandeur integer,
894 lot integer,
895 demandeur integer,
896 petitionnaire_principal boolean
897 );
898
899 ALTER TABLE ONLY lien_lot_demandeur
900 ADD CONSTRAINT lien_lot_demandeur_pkey PRIMARY KEY (lien_lot_demandeur);
901 ALTER TABLE ONLY lien_lot_demandeur
902 ADD CONSTRAINT lien_lot_demandeur_lot_fkey FOREIGN KEY (lot) REFERENCES lot(lot);
903 ALTER TABLE ONLY lien_lot_demandeur
904 ADD CONSTRAINT lien_lot_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur);
905
906 CREATE SEQUENCE lien_lot_demandeur_seq
907 INCREMENT 1
908 MINVALUE 1
909 MAXVALUE 9223372036854775807
910 START 1
911 CACHE 1;
912
913
914 ---
915 --- Nouvelle gestion des tableaux de bord
916 ---
917
918 CREATE TABLE om_dashboard (
919 om_dashboard integer NOT NULL,
920 om_profil integer NOT NULL,
921 bloc character varying(10) NOT NULL,
922 position integer,
923 om_widget integer NOT NULL
924 );
925
926 ALTER TABLE ONLY om_dashboard
927 ADD CONSTRAINT om_dashboard_pkey PRIMARY KEY (om_dashboard);
928 ALTER TABLE ONLY om_dashboard
929 ADD CONSTRAINT om_dashboard_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil);
930 ALTER TABLE ONLY om_dashboard
931 ADD CONSTRAINT om_dashboard_om_widget_fkey FOREIGN KEY (om_widget) REFERENCES om_widget(om_widget);
932
933 CREATE SEQUENCE om_dashboard_seq
934 START WITH 1
935 INCREMENT BY 1
936 NO MINVALUE
937 NO MAXVALUE
938 CACHE 1;
939
940 SELECT pg_catalog.setval('om_dashboard_seq', 1, false);
941
942 ALTER TABLE om_widget
943 DROP CONSTRAINT om_widget_om_profil_fkey;
944
945 ALTER TABlE om_widget DROP COLUMN om_profil;
946
947 ALTER TABLE om_widget ADD COLUMN "type" character varying(40) NOT NULL DEFAULT 'web'::character varying;
948 ALTER TABLE om_widget ALTER COLUMN "lien" SET DEFAULT ''::character varying;
949 ALTER TABLE om_widget ALTER COLUMN "texte" SET DEFAULT ''::text;
950
951 -- Modification de la table civilite
952 ALTER TABLE dossier DROP CONSTRAINT dossier_delegataire_civilite_fkey;
953 ALTER TABLE dossier DROP CONSTRAINT dossier_demandeur_civilite_fkey;
954 ALTER TABLE proprietaire DROP CONSTRAINT proprietaire_civilite_fkey;
955 ALTER TABLE demandeur DROP CONSTRAINT demandeur_particulier_civilite_fkey;
956 ALTER TABLE demandeur DROP CONSTRAINT demandeur_personne_morale_civilite_fkey;
957 ALTER TABLE civilite DROP CONSTRAINT civilite_pkey;
958
959 ALTER TABLE dossier RENAME COLUMN delegataire_civilite TO delegataire_civilite_old;
960 ALTER TABLE dossier RENAME COLUMN demandeur_civilite TO demandeur_civilite_old;
961 ALTER TABLE proprietaire RENAME COLUMN civilite TO civilite_old;
962 ALTER TABLE demandeur RENAME COLUMN particulier_civilite TO particulier_civilite_old;
963 ALTER TABLE demandeur RENAME COLUMN personne_morale_civilite TO personne_morale_civilite_old;
964 ALTER TABLE civilite RENAME COLUMN civilite TO civilite_old;
965
966 CREATE SEQUENCE civilite_seq
967 START WITH 1
968 INCREMENT BY 1
969 NO MAXVALUE
970 NO MINVALUE
971 CACHE 1;
972
973 ALTER TABLE civilite ADD COLUMN civilite integer NOT NULL DEFAULT nextval('civilite_seq'::regclass);
974 ALTER TABLE dossier ADD COLUMN delegataire_civilite integer;
975 ALTER TABLE dossier ADD COLUMN demandeur_civilite integer;
976 ALTER TABLE proprietaire ADD COLUMN civilite integer;
977 ALTER TABLE demandeur ADD COLUMN particulier_civilite integer;
978 ALTER TABLE demandeur ADD COLUMN personne_morale_civilite integer;
979
980 UPDATE dossier SET delegataire_civilite=(select civilite.civilite from civilite where delegataire_civilite_old=civilite.civilite_old);
981 UPDATE dossier SET demandeur_civilite=(select civilite.civilite from civilite where demandeur_civilite_old=civilite.civilite_old);
982 UPDATE proprietaire SET civilite=(select civilite.civilite from civilite where civilite_old=civilite.civilite_old);
983 UPDATE demandeur SET particulier_civilite=(select civilite.civilite from civilite where particulier_civilite_old=civilite.civilite_old);
984 UPDATE demandeur SET personne_morale_civilite=(select civilite.civilite from civilite where personne_morale_civilite_old=civilite.civilite_old);
985
986 ALTER TABLE civilite ADD COLUMN libelle character varying(100);
987 ALTER TABLE civilite ADD COLUMN om_validite_debut date;
988 ALTER TABLE civilite ADD COLUMN om_validite_fin date;
989
990
991 ALTER TABLE civilite RENAME COLUMN civilite_old TO code;
992 ALTER TABLE dossier DROP COLUMN delegataire_civilite_old;
993 ALTER TABLE dossier DROP COLUMN demandeur_civilite_old;
994 ALTER TABLE proprietaire DROP COLUMN civilite_old;
995 ALTER TABLE demandeur DROP COLUMN particulier_civilite_old;
996 ALTER TABLE demandeur DROP COLUMN personne_morale_civilite_old;
997
998 ALTER TABLE ONLY civilite
999 ADD CONSTRAINT civilite_pkey PRIMARY KEY (civilite);
1000
1001 ALTER TABLE ONLY dossier
1002 ADD CONSTRAINT dossier_delegataire_civilite_fkey FOREIGN KEY (delegataire_civilite) REFERENCES civilite(civilite);
1003 ALTER TABLE ONLY dossier
1004 ADD CONSTRAINT dossier_demandeur_civilite_fkey FOREIGN KEY (demandeur_civilite) REFERENCES civilite(civilite);
1005 ALTER TABLE ONLY proprietaire
1006 ADD CONSTRAINT proprietaire_civilite_fkey FOREIGN KEY (civilite) REFERENCES civilite(civilite);
1007 ALTER TABLE ONLY demandeur
1008 ADD CONSTRAINT demandeur_particulier_civilite_fkey FOREIGN KEY (particulier_civilite) REFERENCES civilite(civilite);
1009 ALTER TABLE ONLY demandeur
1010 ADD CONSTRAINT demandeur_personne_morale_civilite_fkey FOREIGN KEY (personne_morale_civilite) REFERENCES civilite(civilite);
1011
1012 ALTER SEQUENCE civilite_seq OWNED BY civilite.civilite;
1013
1014 ALTER TABLE civilite ALTER COLUMN civilite DROP DEFAULT;
1015
1016 UPDATE civilite SET libelle='Monsieur Madame' WHERE civilite = 1 ;
1017 UPDATE civilite SET libelle='Mademoiselle' WHERE civilite = 2 ;
1018 UPDATE civilite SET libelle='Madame' WHERE civilite = 3 ;
1019 UPDATE civilite SET libelle='Monsieur' WHERE civilite = 4 ;
1020
1021 -- Table Lien dossier_autorisation demandeur
1022
1023 CREATE TABLE lien_dossier_autorisation_demandeur (
1024 lien_dossier_autorisation_demandeur integer,
1025 petitionnaire_principal boolean,
1026 dossier_autorisation character varying(20),
1027 demandeur integer
1028 );
1029
1030 ALTER TABLE ONLY lien_dossier_autorisation_demandeur
1031 ADD CONSTRAINT lien_dossier_autorisation_demandeur_pkey PRIMARY KEY (lien_dossier_autorisation_demandeur);
1032 ALTER TABLE ONLY lien_dossier_autorisation_demandeur
1033 ADD CONSTRAINT lien_dossier_autorisation_demandeur_demande_fkey FOREIGN KEY (dossier_autorisation) REFERENCES dossier_autorisation(dossier_autorisation);
1034 ALTER TABLE ONLY lien_dossier_autorisation_demandeur
1035 ADD CONSTRAINT lien_dossier_autorisation_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur);
1036
1037 CREATE SEQUENCE lien_dossier_autorisation_demandeur_seq
1038 INCREMENT 1
1039 MINVALUE 1
1040 MAXVALUE 9223372036854775807
1041 START 1
1042 CACHE 1;
1043
1044 -- Ajout du champ à qualifier --
1045
1046 ALTER TABLE dossier ADD COLUMN a_qualifier boolean;
1047
1048 -- Ajout d'un champ à la table état --
1049 ALTER TABLE etat ADD COLUMN statut character varying(60);
1050 UPDATE etat set statut='encours'
1051 where etat = 'notifier' or etat = 'majorer' or etat = 'initialiser';
1052 UPDATE etat set statut='cloture'
1053 where etat = 'accepter' or etat = 'cloturer' or etat = 'rejeter'
1054 or etat = 'executer' or etat = 'terminer';
1055
1056 --Changement des civilités dans les états et sous-états
1057 UPDATE om_sousetat SET om_sql='
1058 SELECT
1059 ''Commune &commune''||'' ''||''Dossier ''||dossier as dossier, ''Depot ''||to_char(date_depot,''DD/MM/YYYY'')||'' Notifie le ''||COALESCE(to_char(date_complet,''DD/MM/YYYY''),''inconu'') as date_dp_n,
1060 TRIM(CONCAT(civilite.libelle, '' '', demandeur_nom, '' '',demandeur_adresse,'' '',demandeur_cp,'' '',demandeur_ville,'' Parcelle '',parcelle)) as nom_adresse_demandeur,
1061 terrain_numero||'' ''||terrain_numero_complement||'' ''||terrain_adresse||'' ''||terrain_adresse_complement||'' ''||terrain_cp||'' ''||terrain_ville||'' ''||travaux.libelle as adresse_terrain_travaux,
1062 ''shon ''||shon||'' shob ''||shob as SN_SB,
1063 terrain_surface as superficie,
1064 logement_nombre as nbr_logement,
1065 COALESCE(avis_decision.libelle,''inconu'') as avis_decision,
1066 ''Decision''||COALESCE(to_char(date_decision,''DD/MM/YYYY''),''inconu'')||'' Limite ''||COALESCE(to_char(date_limite,''DD/MM/YYYY''),''inconu'') as date_dc_l,
1067 delai||'' mois'' as delai,
1068 '' '' as date_affichage_decision,'' '' as DOC_DAT_Conformite
1069 from &DB_PREFIXEdossier
1070 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1071 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1072 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1073 left join &DB_PREFIXEavis_decision on dossier.avis_decision=avis_decision.avis_decision
1074 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1075 where dossier_autorisation_type_detaille.code=''&nature'' AND (date_decision>=''&datedebut'' AND date_decision<=''&datefin'') ORDER BY dossier'
1076 WHERE om_sousetat = 10;
1077
1078
1079 UPDATE om_etat SET om_sql='select dossier,
1080 dossier_autorisation_type_detaille.libelle as nature,
1081 civilite.libelle AS demandeur_civilite,demandeur_nom,demandeur_societe,
1082 demandeur_adresse,demandeur_cp,demandeur_ville, terrain_numero, terrain_adresse,
1083 terrain_cp, terrain_ville, terrain_surface, hauteur, shon, shob,
1084 batiment_nombre, logement_nombre, delai,
1085 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1086 to_char(date_complet,''DD/MM/YYYY'') as date_complet,
1087 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1088 to_char(date_limite,''DD/MM/YYYY'') as date_limite, travaux.libelle as travaux
1089 from &DB_PREFIXEdossier
1090 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1091 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1092 inner join &DB_PREFIXEnature on nature.nature = dossier.nature
1093 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1094 left join &DB_PREFIXEcivilite on demandeur_civilite=civilite.civilite
1095 where dossier = ''&idx''' WHERE om_etat = 7;
1096
1097 UPDATE om_etat SET om_sql='select service.libelle as service_libelle,
1098 service.adresse as service_adresse, service.cp as service_cp,
1099 service.ville as service_ville, consultation.dossier as dossier,
1100 travaux.libelle as libelle_travaux, civilite.libelle as demandeur_civilite,
1101 date_demande, demandeur_nom, demandeur_adresse, demandeur_cp, demandeur_ville,
1102 terrain_adresse
1103 from &DB_PREFIXEconsultation
1104 inner join &DB_PREFIXEservice on service.service = consultation.service
1105 inner join &DB_PREFIXEdossier on dossier.dossier =consultation.dossier
1106 left join &DB_PREFIXEtravaux on travaux.travaux = dossier.travaux
1107 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1108 where consultation= &idx' WHERE om_etat = 6;
1109
1110 UPDATE om_etat SET om_sql='select service.libelle as service, service.adresse,
1111 service.cp, service.ville, dossier.dossier,
1112 dossier_autorisation_type_detaille.libelle as nature,
1113 civilite.libelle as demandeur_civilite, demandeur_nom, emandeur_societe,
1114 demandeur_adresse, demandeur_cp, demandeur_ville, terrain_numero,
1115 terrain_adresse, terrain_cp, terrain_ville, terrain_surface, hauteur, shon,
1116 shob, batiment_nombre,
1117 logement_nombre, to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1118 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet, travaux.libelle as travaux,
1119 to_char(date_envoi,''DD/MM/YYYY'') as date_envoi
1120 from &DB_PREFIXEconsultation
1121 inner join &DB_PREFIXEdossier on dossier.dossier=consultation.dossier
1122 inner join &DB_PREFIXEservice on service.service=consultation.service
1123 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1124 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1125 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1126 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1127 where consultation = &idx' WHERE om_etat = 4;
1128
1129 UPDATE om_sousetat SET om_sql='SELECT
1130 ''Commune &commune''||'' ''||''Dossier ''||dossier as dossier,to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1131 TRIM(CONCAT( civilite.libelle,'' '', demandeur_nom)) as nom_demandeur,
1132 terrain_numero||'' ''||terrain_numero_complement||'' ''||terrain_adresse||'' ''||terrain_adresse_complement||'' ''||terrain_cp||'' ''||terrain_ville as adresse_terrain,
1133 shon, logement_nombre as nb_logt
1134 from &DB_PREFIXEdossier
1135 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1136 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1137 inner join &DB_PREFIXEdossier_autorisation_type on dossier_autorisation_type.dossier_autorisation_type=dossier_autorisation_type_detaille.dossier_autorisation_type
1138 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1139 where &DB_PREFIXEdossier_autorisation_type.code=''&nature'' AND (date_depot>=''&datedebut'' AND date_depot<=''&datefin'')
1140 ORDER BY dossier' WHERE om_sousetat = 9;
1141
1142 UPDATE om_sousetat SET om_sql='SELECT
1143 ''Commune &commune''||'' ''||''Dossier ''||dossier as dossier,
1144 ''Depot ''||to_char(date_depot,''DD/MM/YYYY'')||'' Notifie le ''||COALESCE(to_char(date_complet,''DD/MM/YYYY''),''inconu'') as date_dp_n,
1145 TRIM(CONCAT(civilite.libelle,'' '',demandeur_nom,'' '',demandeur_adresse,'' '',demandeur_cp,'' '',demandeur_ville,'' Parcelle '',parcelle)) as nom_adresse_demandeur,
1146 terrain_numero||'' ''||terrain_numero_complement||'' ''||terrain_adresse||'' ''||terrain_adresse_complement||'' ''||terrain_cp||'' ''||terrain_ville||'' ''||travaux.libelle as adresse_terrain_travaux,
1147 ''shon ''||shon||'' shob ''||shob as SN_SB, terrain_surface as superficie,
1148 logement_nombre as nbr_logement, COALESCE(avis_decision.libelle,''inconu'') as avis_decision,
1149 ''Decision''||COALESCE(to_char(date_decision,''DD/MM/YYYY''),''inconu'')||'' Limite ''||COALESCE(to_char(date_limite,''DD/MM/YYYY''),''inconu'') as date_dc_l,
1150 delai||'' mois'' as delai, '' '' as date_affichage_decision, '' '' as DOC_DAT_Conformite
1151 from &DB_PREFIXEdossier
1152 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1153 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1154 inner join &DB_PREFIXEdossier_autorisation_type on dossier_autorisation_type.dossier_autorisation_type=dossier_autorisation_type_detaille.dossier_autorisation_type
1155 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1156 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1157 left join &DB_PREFIXEavis_decision on dossier.avis_decision=avis_decision.avis_decision
1158 where dossier_autorisation_type.code=''&nature'' AND (date_depot>=''&datedebut'' AND date_depot<=''&datefin'')
1159 ORDER BY dossier' WHERE om_sousetat = 8;
1160
1161 -- Ajout d'un nouvel état et d'un nouvel sous-état pour les affichages des dossiers / ! \ GROUPE a rajouter
1162 INSERT INTO om_etat VALUES (nextval('om_etat_seq'), 1, 'dossier_m',
1163 'import du 25/11/2012', true, 'L', 'A4', 'helvetica',
1164 'I', 8, 'pixel.png', 58, 7, 'Registre des dossiers en cours',
1165 5, 7, 100, 10, 'helvetica', 'B', 15, '1', 'L', '
1166 No commune : &departement &commune &ville', 120, 7, 195, 5, 'helvetica', '', 10, '0', 'J',
1167 'select nom from &DB_PREFIXEom_utilisateur', 'dossier_m', 'helvetica', 8, 5, 5, '0-0-0');
1168
1169 INSERT INTO om_sousetat VALUES (nextval('om_sousetat_seq'), 1, 'dossier_m',
1170 'import du 26/11/2012', true, 'Edition du &aujourdhui',
1171 8, 'helvetica', '', 9, '0', 'L', '0', '243-246-246',
1172 '0-0-0', 5, 0, '1', '1', '0|0|0|0|0|0|90|90|0|0|0|90|90',
1173 37, 'TLB|LTB|LTBR|TLB|LTB|LTBR|TLB|LTB|LTBR|LTBR|TLB|LTB|LTBR|LTBR|LTBR',
1174 'C|C|C|L|L|R|R|R|L|R|R|R|R', '145-184-189', '0-0-0',
1175 280, '1', 7, '0-0-0', '243-246-246', '255-255-255',
1176 '1', 9, '20|20|20|50|57|15|15|10|20|20|11|21|21',
1177 'LTBR|LTBR|LTBRL|LTBR|LTBR|LTBRL|LTBR|LTBR|LTBR|LTBRL|LTBR|LTBR|LTBR',
1178 'LTBR|LTBR|LTBR|LTBR|LTBR|LTBRL|LTBR|LTBR|LTBR|LTBRL|LTBR|LTBR|LTBR',
1179 'C|C|C|L|L|C|R|R|L|C|R|C|C', '1', 10, 15, '196-213-215',
1180 'TBL|TBL|TBL|TBLR|TBL|TBL|TBLR|TBLR|TBL|TBL|TBLR|TBLR|TBLR',
1181 'L|L|L|C|L|L|C|C|L|L|C|C|C', '1', 10, 5, '212-219-220',
1182 'BTL|BTL|BTL|BTLR|BTL|BTL|BTLR|TBLR|BTL|BTL|BTLR|TBLR|TBLR',
1183 'L|L|L|C|L|L|C|C|L|L|C|C|C', '1', 10, 15, '255-255-255',
1184 'TBL|TBL|TBL|TBLR|TBL|TBL|TBLR|TBLR|TBL|TBL|TBLR|TBLR|TBLR',
1185 'L|L|L|R|L|L|R|R|L|L|R|R|R', '999|999|999|999|999|999|999|999|999|999|999|999|999',
1186 '0|0|0|0|0|0|0|0|0|0|0|0|0', '0|0|0|0|0|0|0|0|0|0|0|0|0',
1187 '0|0|0|0|0|0|0|0|0|0|0|0|0', 'SELECT
1188 CONCAT(''Commune &commune'','' '',''Dossier '', dossier) as dossier,
1189 CONCAT(''Depot '', to_char(date_depot,''DD/MM/YYYY''), '' Notifie le '',
1190 COALESCE(to_char(date_complet,''DD/MM/YYYY''),''inconu'')) as date_dp_n,
1191 arrondissement.libelle as arrondissement,
1192 TRIM(CONCAT(civilite.libelle,'' '',demandeur_nom,'' '',demandeur_adresse,'' '',demandeur_cp,'' '',demandeur_ville,'' Parcelle '',parcelle)) as nom_adresse_demandeur,
1193 CONCAT(dossier.terrain_adresse_voie_numero, '' '', dossier.complement, '' '', dossier.terrain_adresse_code_postal, '' '', dossier.terrain_adresse_localite, '' '', travaux.libelle) as adresse_terrain_travaux,
1194 CONCAT(''shon '', shon, '' shob '', shob) as SN_SB,
1195 terrain_surface as superficie,
1196 logement_nombre as nbr_logement,
1197 COALESCE(avis_decision.libelle,''inconu'') as avis_decision,
1198 CONCAT(''Decision'', COALESCE(to_char(date_decision,''DD/MM/YYYY''),''inconu''), '' Limite '', COALESCE(to_char(date_limite,''DD/MM/YYYY''),''inconu'')) as date_dc_l,
1199 CONCAT(delai, '' mois'') as delai,
1200 '' '' as date_affichage_decision,
1201 '' '' as DOC_DAT_Conformite
1202 FROM
1203 &DB_PREFIXEdossier
1204 INNER JOIN
1205 &DB_PREFIXEdossier_autorisation
1206 ON
1207 dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1208 INNER JOIN
1209 &DB_PREFIXEdossier_autorisation_type_detaille
1210 ON
1211 dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
1212 INNER JOIN
1213 &DB_PREFIXEdossier_autorisation_type
1214 ON
1215 dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type
1216 LEFT JOIN
1217 &DB_PREFIXEcivilite
1218 ON
1219 demandeur_civilite = civilite.civilite
1220 LEFT JOIN
1221 &DB_PREFIXEtravaux
1222 ON
1223 dossier.travaux=travaux.travaux
1224 LEFT JOIN
1225 &DB_PREFIXEavis_decision
1226 ON
1227 dossier.avis_decision=avis_decision.avis_decision
1228 LEFT JOIN
1229 &DB_PREFIXEarrondissement
1230 ON
1231 dossier.terrain_adresse_code_postal = arrondissement.code_postal
1232 WHERE
1233 (select e.statut from &DB_PREFIXEetat e where e.etat = dossier.etat ) = ''encours''
1234 ORDER BY
1235 dossier_autorisation_type.libelle, arrondissement.libelle');
1236
1237 -- Ajout d'un nouvel évènement "affichage_obligatoire"
1238 INSERT INTO evenement VALUES (89, 'affichage_obligatoire', 'T', 'divers', NULL, 0, 'Non', 0, 'attestation_affichage', ' ', NULL);
1239 ALTER SEQUENCE evenement_seq RESTART WITH 90;
1240
1241 -- Ajout d'un nouveau paramètre pour l'évènement "affichage_obligatoire"
1242 INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'), 'affichage_obligatoire', '89', 1);
1243
1244 -- Ajout des colonnes manquant dans dossier por rapport à la table demande
1245 ALTER TABLE dossier ADD COLUMN terrain_references_cadastrales character varying(100);
1246 ALTER TABLE dossier ADD COLUMN terrain_adresse_voie_numero integer;
1247 ALTER TABLE dossier ADD COLUMN complement character varying(30);
1248 ALTER TABLE dossier ADD COLUMN terrain_adresse_lieu_dit character varying(30);
1249 ALTER TABLE dossier ADD COLUMN terrain_adresse_localite character varying(30);
1250 ALTER TABLE dossier ADD COLUMN terrain_adresse_code_postal character varying(5);
1251 ALTER TABLE dossier ADD COLUMN terrain_adresse_bp character varying(15);
1252 ALTER TABLE dossier ADD COLUMN terrain_adresse_cedex character varying(15);
1253 ALTER TABLE dossier ADD COLUMN terrain_superficie double precision;
1254
1255 -- Ajout d'une nouvelle lettre type
1256 INSERT INTO om_lettretype VALUES (nextval('om_lettretype_seq'), 1, 'attestation_affichage', 'attestion d''affichage obligatoire', true, 'P', 'A4', 'logolettretype.png', 8, 9, 'Attestation d''affichage', 70, 20, 130, 5, 'arial', '', 8, '1', 'L', 'Bonjour', 30, 102, 160, 4, 'arial', '', 8, '0', 'J', 'select nom from &DB_PREFIXEom_utilisateur');
1257
1258 -- Table Lien demande demandeur
1259
1260 CREATE TABLE lien_dossier_demandeur (
1261 lien_dossier_demandeur integer,
1262 petitionnaire_principal boolean,
1263 dossier character varying(20),
1264 demandeur integer
1265 );
1266
1267 ALTER TABLE ONLY lien_dossier_demandeur
1268 ADD CONSTRAINT lien_dossier_demandeur_pkey PRIMARY KEY (lien_dossier_demandeur);
1269 ALTER TABLE ONLY lien_dossier_demandeur
1270 ADD CONSTRAINT lien_dossier_demandeur_dossier_fkey FOREIGN KEY (dossier) REFERENCES dossier(dossier);
1271 ALTER TABLE ONLY lien_dossier_demandeur
1272 ADD CONSTRAINT lien_dossier_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur);
1273
1274 CREATE SEQUENCE lien_dossier_demandeur_seq
1275 INCREMENT 1
1276 MINVALUE 1
1277 MAXVALUE 9223372036854775807
1278 START 1
1279 CACHE 1;
1280
1281 ALTER TABLE dossier ALTER nature TYPE character varying(3);
1282 ALTER TABLE nature ALTER nature TYPE character varying(3);
1283 ALTER TABLE nature ALTER libelle TYPE character varying(150);
1284 ALTER TABLE dossier ALTER nature DROP NOT NULL;
1285
1286 INSERT INTO nature VALUES ('PCI', 'Permis de construire pour une maison individuelle et / ou ses annexes');
1287 INSERT INTO nature VALUES ('PCA', 'Permis de construire comprenant ou non des démolitions');
1288 INSERT INTO nature VALUES ('AZ', 'Demande d''autorisation spéciale de travaux dans le périmètre d''une AVAP');
1289 INSERT INTO nature VALUES ('DAT', 'Demande d''autorisation de construire, d''aménager ou de modifier un ERP');
1290
1291 ALTER TABLE dossier ALTER COLUMN dossier TYPE character varying(20);
1292
1293 ALTER TABLE dossier ADD column dossier_autorisation character varying(20) NOT NULL;
1294 ALTER TABLE ONLY dossier
1295 ADD CONSTRAINT dossier_dossier_autorisation_fkey FOREIGN KEY (dossier_autorisation) REFERENCES dossier_autorisation(dossier_autorisation);
1296
1297 ALTER TABLE instruction ALTER COLUMN dossier TYPE character varying(20);
1298
1299 ALTER TABLE instruction ALTER COLUMN dossier TYPE character varying(20);
1300 ALTER TABLE consultation ALTER COLUMN dossier TYPE character varying(20);
1301 ALTER TABLE terrain ALTER COLUMN dossier TYPE character varying(20);
1302 ALTER TABLE blocnote ALTER COLUMN dossier TYPE character varying(20);
1303 ALTER TABLE destination_shon ALTER COLUMN dossier TYPE character varying(20);
1304 ALTER TABLE statistique ALTER COLUMN dossier TYPE character varying(20);
1305
1306 INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'), 'option_ERP', 'true', 1);
1307 INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'), 'option_GED', 'false', 1);
1308
1309 ALTER TABLE om_utilisateur ALTER COLUMN email TYPE character varying(100);
1310
1311
1312 ---
1313 --- GESTION DES COMMISSIONS
1314 ---
1315
1316 CREATE TABLE commission_type (
1317 commission_type integer NOT NULL,
1318 code character varying(10),
1319 libelle character varying(100),
1320
1321 lieu_adresse_ligne1 character varying(100),
1322 lieu_adresse_ligne2 character varying(100),
1323
1324 lieu_salle character varying(100),
1325
1326 listes_de_diffusion text,
1327
1328 participants text,
1329
1330 corps_du_courriel text,
1331
1332 om_validite_debut date,
1333 om_validite_fin date
1334 );
1335
1336 CREATE TABLE commission (
1337 commission integer NOT NULL,
1338
1339 code character varying(20),
1340
1341 commission_type integer NOT NULL,
1342
1343 libelle character varying(100),
1344
1345 date_commission date NOT NULL,
1346 heure_commission character varying(5),
1347
1348 lieu_adresse_ligne1 character varying(100),
1349 lieu_adresse_ligne2 character varying(100),
1350
1351 lieu_salle character varying(100),
1352
1353 listes_de_diffusion text,
1354
1355 participants text
1356 );
1357
1358 CREATE TABLE dossier_commission (
1359 dossier_commission integer NOT NULL,
1360
1361 dossier character varying(20) NOT NULL,
1362
1363 commission_type integer NOT NULL,
1364 date_souhaitee date NOT NULL,
1365 motivation text,
1366
1367
1368 commission integer,
1369
1370 avis text,
1371 lu boolean default FALSE
1372 );
1373
1374 ALTER TABLE ONLY commission_type
1375 ADD CONSTRAINT commission_type_pkey PRIMARY KEY(commission_type);
1376 ALTER TABLE ONLY commission
1377 ADD CONSTRAINT commission_pkey PRIMARY KEY(commission);
1378 ALTER TABLE ONLY dossier_commission
1379 ADD CONSTRAINT dossier_commission_pkey PRIMARY KEY(dossier_commission);
1380
1381
1382 ALTER TABLE ONLY dossier_commission
1383 ADD CONSTRAINT dossier_commission_dossier_fkey FOREIGN KEY (dossier) REFERENCES dossier(dossier);
1384
1385 ALTER TABLE ONLY commission
1386 ADD CONSTRAINT commission_commission_type_fkey FOREIGN KEY (commission_type) REFERENCES commission_type(commission_type);
1387
1388 ALTER TABLE ONLY dossier_commission
1389 ADD CONSTRAINT dossier_commission_commission_fkey FOREIGN KEY (commission) REFERENCES commission(commission);
1390
1391 ALTER TABLE ONLY dossier_commission
1392 ADD CONSTRAINT dossier_commission_commission_type_fkey FOREIGN KEY (commission_type) REFERENCES commission_type(commission_type);
1393
1394
1395 CREATE SEQUENCE commission_type_seq
1396 START WITH 1
1397 INCREMENT BY 1
1398 NO MINVALUE
1399 NO MAXVALUE
1400 CACHE 1;
1401
1402 CREATE SEQUENCE commission_seq
1403 START WITH 1
1404 INCREMENT BY 1
1405 NO MINVALUE
1406 NO MAXVALUE
1407 CACHE 1;
1408
1409 CREATE SEQUENCE dossier_commission_seq
1410 START WITH 1
1411 INCREMENT BY 1
1412 NO MINVALUE
1413 NO MAXVALUE
1414 CACHE 1;
1415
1416
1417 ---
1418 --- FIN GESTION DES COMMISSIONS
1419 ---
1420
1421 -- Suppression du champ action et ajout du champs evenement dans la table transition
1422 -- Création d'une table temporaire
1423
1424 CREATE TABLE transition_tmp (
1425 transition_tmp integer NOT NULL,
1426 etat character varying(20) NOT NULL,
1427 evenement integer NOT NULL
1428 );
1429
1430 CREATE SEQUENCE transition_tmp_seq
1431 START WITH 1
1432 INCREMENT BY 1
1433 NO MINVALUE
1434 NO MAXVALUE
1435 CACHE 1;
1436
1437 -- Ajout des données
1438 INSERT INTO transition_tmp ( transition_tmp, etat, evenement)
1439 SELECT
1440 nextval('transition_tmp_seq'), transition.etat, evenement.evenement
1441 FROM
1442 transition
1443 LEFT JOIN
1444 evenement
1445 ON
1446 transition.action=evenement.action;
1447
1448 -- Suppression de l'ancienne table et des contraintes
1449 ALTER TABLE transition DROP CONSTRAINT transition_pkey;
1450 ALTER TABLE transition DROP CONSTRAINT transition_action_fkey;
1451 ALTER TABLE transition DROP CONSTRAINT transition_etat_fkey;
1452 DROP SEQUENCE transition_seq;
1453 DROP TABLE transition;
1454
1455 -- Renommage de la table, champ, ajout contraintes PK + FK, renommage de la séquence
1456 ALTER TABLE transition_tmp RENAME TO transition;
1457 ALTER TABLE transition RENAME COLUMN transition_tmp TO transition;
1458
1459 ALTER TABLE ONLY transition
1460 ADD CONSTRAINT transition_pkey PRIMARY KEY(transition);
1461
1462 ALTER TABLE ONLY transition
1463 ADD CONSTRAINT transition_etat_fkey FOREIGN KEY (etat) REFERENCES etat(etat);
1464
1465 ALTER TABLE ONLY transition
1466 ADD CONSTRAINT transition_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement);
1467
1468 ALTER TABLE transition_tmp_seq RENAME TO transition_seq;
1469 ALTER TABLE transition ALTER COLUMN transition SET DEFAULT NEXTVAL('transition_seq');
1470
1471
1472
1473 -- Création de la table "lien_dossier_instruction_type_evenement"
1474 CREATE TABLE lien_dossier_instruction_type_evenement (
1475 lien_dossier_instruction_type_evenement integer,
1476 dossier_instruction_type integer,
1477 evenement integer
1478 );
1479
1480 ALTER TABLE ONLY lien_dossier_instruction_type_evenement
1481 ADD CONSTRAINT lien_dossier_instruction_type_evenement_pkey PRIMARY KEY (lien_dossier_instruction_type_evenement);
1482 ALTER TABLE ONLY lien_dossier_instruction_type_evenement
1483 ADD CONSTRAINT lien_dossier_instruction_type_evenement_dossier_instruction_type_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type);
1484 ALTER TABLE ONLY lien_dossier_instruction_type_evenement
1485 ADD CONSTRAINT lien_dossier_instruction_type_evenement_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement);
1486
1487 CREATE SEQUENCE lien_dossier_instruction_type_evenement_seq
1488 INCREMENT 1
1489 MINVALUE 1
1490 MAXVALUE 9223372036854775807
1491 START 1
1492 CACHE 1;
1493
1494
1495 ---
1496 --- Suppression de la table nature
1497 ---
1498
1499 --- Table travaux : remplacement de la colonne nature par dossier_autorisation_type
1500 ALTER TABLE ONLY travaux ADD COLUMN dossier_autorisation_type integer;
1501
1502 UPDATE travaux SET dossier_autorisation_type =
1503 (SELECT dossier_autorisation_type FROM dossier_autorisation_type
1504 WHERE dossier_autorisation_type.code=travaux.nature);
1505
1506 ALTER TABLE ONLY travaux
1507 ADD CONSTRAINT travaux_dossier_autorisation_type_fkey
1508 FOREIGN KEY (dossier_autorisation_type)
1509 REFERENCES dossier_autorisation_type(dossier_autorisation_type);
1510
1511 ALTER TABLE ONLY travaux DROP COLUMN nature;
1512
1513 --- Table dossier : suppression de la colonne nature
1514 ALTER TABLE ONLY dossier DROP COLUMN nature;
1515
1516 --- Table evenement : suppression de la colonne nature (liaison N à N avec dossier_autorisation_type_detaille)
1517 INSERT INTO lien_dossier_instruction_type_evenement
1518 SELECT nextval('lien_dossier_instruction_type_evenement_seq'),dossier_instruction_type.dossier_instruction_type,evenement.evenement
1519 FROM evenement
1520 INNER JOIN dossier_autorisation_type
1521 ON dossier_autorisation_type.code=evenement.nature
1522 INNER JOIN dossier_autorisation_type_detaille
1523 ON dossier_autorisation_type_detaille.dossier_autorisation_type=dossier_autorisation_type.dossier_autorisation_type
1524 INNER JOIN dossier_instruction_type
1525 ON dossier_instruction_type.dossier_autorisation_type_detaille=dossier_autorisation_type_detaille.dossier_autorisation_type_detaille;
1526
1527 INSERT INTO lien_dossier_instruction_type_evenement
1528 SELECT nextval('lien_dossier_instruction_type_evenement_seq'),dossier_instruction_type,evenement
1529 FROM evenement AS e INNER JOIN dossier_instruction_type AS dit on e.nature='T';
1530
1531 ALTER TABLE ONLY evenement DROP COLUMN nature;
1532
1533 --- Table bible : remplacement de la colonne nature par dossier_autorisation_type
1534
1535 ALTER TABLE bible ADD COLUMN dossier_autorisation_type integer;
1536
1537 UPDATE bible SET dossier_autorisation_type=(
1538 SELECT dossier_autorisation_type
1539 FROM dossier_autorisation_type
1540 WHERE dossier_autorisation_type.code=bible.nature
1541 );
1542
1543 ALTER TABLE bible DROP COLUMN nature;
1544
1545 --- Suppression de la table nature
1546 DROP TABLE nature;
1547
1548 --- Mise à jour des etats
1549
1550 UPDATE om_etat SET om_sql = 'select
1551 dossier,dossier_autorisation_type_detaille.libelle as nature,
1552 demandeur_civilite,demandeur_nom,demandeur_societe,
1553 demandeur_adresse,demandeur_cp,demandeur_ville,
1554 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1555 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre, delai,
1556 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1557 to_char(date_complet,''DD/MM/YYYY'') as date_complet,
1558 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1559 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1560 travaux.libelle as travaux
1561 from &DB_PREFIXEdossier
1562 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1563 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1564 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1565 where dossier = ''&idx''' WHERE om_etat = 7;
1566
1567 UPDATE om_etat SET om_sql = 'select service.libelle as service, service.adresse,
1568 service.cp, service.ville, dossier.dossier,
1569 dossier_autorisation_type_detaille.libelle as nature,
1570 civilite.libelle as demandeur_civilite, demandeur_nom, emandeur_societe,
1571 demandeur_adresse, demandeur_cp, demandeur_ville, terrain_numero,
1572 terrain_adresse, terrain_cp, terrain_ville, terrain_surface, hauteur, shon,
1573 shob, batiment_nombre,
1574 logement_nombre, to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1575 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet, travaux.libelle as travaux,
1576 to_char(date_envoi,''DD/MM/YYYY'') as date_envoi
1577 from &DB_PREFIXEconsultation
1578 inner join &DB_PREFIXEdossier on dossier.dossier=consultation.dossier
1579 inner join &DB_PREFIXEservice on service.service=consultation.service
1580 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1581 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1582 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1583 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1584 where consultation = &idx' WHERE om_etat = 4;
1585
1586 UPDATE om_etat SET om_sql = 'select service.libelle as service_libelle,
1587 service.adresse as service_adresse, service.cp as service_cp,
1588 service.ville as service_ville, consultation.dossier as dossier,
1589 travaux.libelle as libelle_travaux, civilite.libelle as demandeur_civilite,
1590 date_demande, demandeur_nom, demandeur_adresse, demandeur_cp, demandeur_ville,
1591 terrain_adresse
1592 from &DB_PREFIXE consultation
1593 inner join &DB_PREFIXEservice on service.service = consultation.service
1594 inner join &DB_PREFIXEdossier on dossier.dossier =consultation.dossier
1595 left join &DB_PREFIXEtravaux on travaux.travaux = dossier.travaux
1596 left join &DB_PREFIXEcivilite on demandeur_civilite = civilite.civilite
1597 where consultation= &idx' WHERE om_etat = 6;
1598
1599 UPDATE om_etat SET om_sql = 'select nom from &DB_PREFIXEom_utilisateur' WHERE om_etat = 5;
1600
1601 UPDATE om_etat SET om_sql = 'select nom from &DB_PREFIXEom_utilisateur' WHERE om_etat = 3;
1602
1603 UPDATE om_etat SET om_sql = 'select nom from &DB_PREFIXEom_utilisateur' WHERE om_etat = 2;
1604
1605 UPDATE om_lettretype SET om_sql = 'select
1606 dossier,dossier_autorisation_type_detaille.libelle as nature,
1607 demandeur_civilite,demandeur_nom,demandeur_societe,
1608 demandeur_adresse,demandeur_cp,demandeur_ville,
1609 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1610 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
1611 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1612 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet,
1613 travaux.libelle as travaux
1614 from &DB_PREFIXEdossier
1615 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1616 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1617 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1618 where dossier = ''&destinataire''' WHERE om_lettretype = 2;
1619
1620 UPDATE om_lettretype SET om_sql = 'select
1621 dossier,dossier_autorisation_type_detaille.libelle as nature,
1622 demandeur_civilite,demandeur_nom,demandeur_societe,
1623 demandeur_adresse,demandeur_cp,demandeur_ville,
1624 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1625 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1626 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1627 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1628 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1629 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email,om_utilisateur.telephone
1630 from &DB_PREFIXEdossier
1631 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1632 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1633 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1634 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1635 where dossier = ''&destinataire''' WHERE om_lettretype = 3;
1636
1637 UPDATE om_lettretype SET om_sql = 'select
1638 dossier,dossier_autorisation_type_detaille.libelle as nature,
1639 demandeur_civilite,demandeur_nom,demandeur_societe,
1640 demandeur_adresse,demandeur_cp,demandeur_ville,
1641 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1642 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1643 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1644 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1645 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1646 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
1647 from &DB_PREFIXEdossier
1648 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1649 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1650 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1651 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1652 where dossier = ''&destinataire''' WHERE om_lettretype = 4;
1653
1654 UPDATE om_lettretype SET om_sql = 'select
1655 dossier,dossier_autorisation_type_detaille.libelle as nature,
1656 demandeur_civilite,demandeur_nom,demandeur_societe,
1657 demandeur_adresse,demandeur_cp,demandeur_ville,
1658 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1659 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1660 concat(substring(date_depot,9,2),''/'',substring(date_depot,6,2),''/'',substring(date_depot,1,4)) as date_depot, concat(substring(date_notification_delai,9,2),''/'',substring(date_notification_delai,6,2),''/'',substring(date_notification_delai,1,4)) as date_notification_delai,
1661 concat(substring(date_limite,9,2),''/'',substring(date_limite,6,2),''/'',substring(date_limite,1,4)) as date_limite,
1662 travaux.libelle as travaux
1663 from &DB_PREFIXEdossier
1664 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1665 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1666 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1667 where dossier = ''&destinataire''' WHERE om_lettretype = 5;
1668
1669 UPDATE om_lettretype SET om_sql = 'select
1670 dossier,dossier_autorisation_type_detaille.libelle as nature,
1671 demandeur_civilite,demandeur_nom,demandeur_societe,
1672 demandeur_adresse,demandeur_cp,demandeur_ville,
1673 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1674 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1675 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1676 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1677 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1678 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
1679 from &DB_PREFIXEdossier
1680 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1681 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1682 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1683 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1684 where dossier = ''&destinataire''' WHERE om_lettretype = 6;
1685
1686 UPDATE om_lettretype SET om_sql = 'select
1687 dossier,dossier_autorisation_type_detaille.libelle as nature,
1688 demandeur_civilite,demandeur_nom,demandeur_societe,
1689 demandeur_adresse,demandeur_cp,demandeur_ville,
1690 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1691 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre, delai,
1692 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1693 to_char(date_complet,''DD/MM/YYYY'') as date_complet, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1694 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1695 travaux.libelle as travaux
1696 from &DB_PREFIXEdossier
1697 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1698 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1699 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1700 where dossier = ''&destinataire''' WHERE om_lettretype = 7;
1701
1702 UPDATE om_lettretype SET om_sql = 'select
1703 dossier,dossier_autorisation_type_detaille.libelle as nature,
1704 demandeur_civilite,demandeur_nom,demandeur_societe,
1705 demandeur_adresse,demandeur_cp,demandeur_ville,
1706 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1707 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
1708 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1709 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1710 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1711 travaux.libelle as travaux
1712 from &DB_PREFIXEdossier
1713 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1714 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1715 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1716 where dossier = ''&destinataire''' WHERE om_lettretype = 8;
1717
1718 UPDATE om_lettretype SET om_sql = 'select
1719 dossier,dossier_autorisation_type_detaille.libelle as nature,
1720 demandeur_civilite,demandeur_nom,demandeur_societe,
1721 demandeur_adresse,demandeur_cp,demandeur_ville,
1722 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1723 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1724 to_char(date_depot,''DD/MM/YYYY'') as date_depot, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1725 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1726 to_char(date_complet,''DD/MM/YYYY'') as date_complet,
1727 travaux.libelle as travaux
1728 from &DB_PREFIXEdossier
1729 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1730 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1731 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1732 where dossier = ''&destinataire''' WHERE om_lettretype = 9;
1733
1734 UPDATE om_lettretype SET om_sql = 'select
1735 dossier,dossier_autorisation_type_detaille.libelle as nature,
1736 demandeur_civilite,demandeur_nom,demandeur_societe,
1737 demandeur_adresse,demandeur_cp,demandeur_ville,
1738 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1739 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1740 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1741 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1742 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1743 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
1744 from &DB_PREFIXEdossier
1745 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1746 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1747 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1748 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1749 where dossier = ''&destinataire''' WHERE om_lettretype = 25;
1750
1751 UPDATE om_lettretype SET om_sql = 'select
1752 dossier,dossier_autorisation_type_detaille.libelle as nature,
1753 demandeur_civilite,demandeur_nom,demandeur_societe,
1754 demandeur_adresse,demandeur_cp,demandeur_ville,
1755 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1756 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1757 to_char(date_depot,''DD/MM/YYYY'') as date_depot, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1758 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1759 to_char(date_decision,''DD/MM/YYYY'') as date_decision,
1760 travaux.libelle as travaux
1761 from &DB_PREFIXEdossier
1762 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1763 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1764 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1765 where dossier = ''&destinataire''' WHERE om_lettretype = 10;
1766
1767 UPDATE om_lettretype SET om_sql = 'select
1768 dossier,dossier_autorisation_type_detaille.libelle as nature,
1769 demandeur_civilite,demandeur_nom,demandeur_societe,
1770 demandeur_adresse,demandeur_cp,demandeur_ville,
1771 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1772 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1773 to_char(date_depot,''DD/MM/YYYY'') as date_depot, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1774 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1775 travaux.libelle as travaux
1776 from &DB_PREFIXEdossier
1777 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1778 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1779 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1780 where dossier = ''&destinataire''' WHERE om_lettretype = 11;
1781
1782 UPDATE om_lettretype SET om_sql = 'select
1783 dossier,dossier_autorisation_type_detaille.libelle as nature,
1784 demandeur_civilite,demandeur_nom,demandeur_societe,
1785 demandeur_adresse,demandeur_cp,demandeur_ville,
1786 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1787 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1788 to_char(date_depot,''DD/MM/YYYY'') as date_depot, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1789 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1790 travaux.libelle as travaux
1791 from &DB_PREFIXEdossier
1792 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1793 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1794 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1795 where dossier = ''&destinataire''' WHERE om_lettretype = 12;
1796
1797 UPDATE om_lettretype SET om_sql = 'select
1798 dossier,dossier_autorisation_type_detaille.libelle as nature,
1799 demandeur_civilite,demandeur_nom,demandeur_societe,
1800 demandeur_adresse,demandeur_cp,demandeur_ville,
1801 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1802 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1803 to_char(date_depot,''DD/MM/YYYY'') as date_depot, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1804 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1805 travaux.libelle as travaux
1806 from &DB_PREFIXEdossier
1807 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1808 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1809 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1810 where dossier = ''&destinataire''' WHERE om_lettretype = 13;
1811
1812 UPDATE om_lettretype SET om_sql = 'select
1813 dossier,dossier_autorisation_type_detaille.libelle as nature,
1814 demandeur_civilite,demandeur_nom,demandeur_societe,
1815 demandeur_adresse,demandeur_cp,demandeur_ville,
1816 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1817 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1818 to_char(date_depot,''DD/MM/YYYY'') as date_depot, to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1819 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1820 travaux.libelle as travaux
1821 from &DB_PREFIXEdossier
1822 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1823 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1824 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1825 where dossier = ''&destinataire''' WHERE om_lettretype = 14;
1826
1827 UPDATE om_lettretype SET om_sql = 'select dossier,
1828 dossier_autorisation_type_detaille.libelle as nature, demandeur_civilite,
1829 demandeur_nom,demandeur_societe, demandeur_adresse,
1830 demandeur_cp,demandeur_ville,
1831 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1832 terrain_surface,
1833 hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1834 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1835 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1836 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1837 travaux.libelle as travaux,
1838 om_utilisateur.nom,
1839 om_utilisateur.email,
1840 om_utilisateur.telephone
1841 from &DB_PREFIXEdossier
1842 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1843 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1844 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1845 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1846 where dossier = ''&destinataire''' WHERE om_lettretype = 15;
1847
1848 UPDATE om_lettretype SET om_sql = 'select
1849 dossier,dossier_autorisation_type_detaille.libelle as nature,
1850 demandeur_civilite,demandeur_nom,demandeur_societe,
1851 demandeur_adresse,demandeur_cp,demandeur_ville,
1852 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1853 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1854 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1855 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1856 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1857 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
1858 from &DB_PREFIXEdossier
1859 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1860 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1861 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1862 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1863 where dossier = ''&destinataire''' WHERE om_lettretype = 16;
1864
1865 UPDATE om_lettretype SET om_sql = 'select
1866 dossier,dossier_autorisation_type_detaille.libelle as nature,
1867 demandeur_civilite,demandeur_nom,demandeur_societe,
1868 demandeur_adresse,demandeur_cp,demandeur_ville,
1869 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1870 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
1871 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1872 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1873 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1874 travaux.libelle as travaux
1875 from &DB_PREFIXEdossier
1876 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1877 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1878 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1879 where dossier = ''&destinataire''' WHERE om_lettretype = 17;
1880
1881 UPDATE om_lettretype SET om_sql = 'select
1882 dossier,dossier_autorisation_type_detaille.libelle as nature, delai,
1883 demandeur_civilite,demandeur_nom,demandeur_societe,
1884 demandeur_adresse,demandeur_cp,demandeur_ville,
1885 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1886 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
1887 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1888 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet,
1889 travaux.libelle as travaux
1890 from &DB_PREFIXEdossier
1891 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1892 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1893 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1894 where dossier = ''&destinataire''' WHERE om_lettretype = 18;
1895
1896 UPDATE om_lettretype SET om_sql = 'select
1897 dossier,dossier_autorisation_type_detaille.libelle as nature,
1898 demandeur_civilite,demandeur_nom,demandeur_societe,
1899 demandeur_adresse,demandeur_cp,demandeur_ville,
1900 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1901 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1902 concat(substring(date_depot,9,2),''/'',substring(date_depot,6,2),''/'',substring(date_depot,1,4)) as date_depot, concat(substring(date_notification_delai,9,2),''/'',substring(date_notification_delai,6,2),''/'',substring(date_notification_delai,1,4)) as date_notification_delai,
1903 concat(substring(date_limite,9,2),''/'',substring(date_limite,6,2),''/'',substring(date_limite,1,4)) as date_limite,
1904 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email,om_utilisateur.telephone
1905 from &DB_PREFIXEdossier
1906 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1907 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1908 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1909 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1910 where dossier = ''&destinataire''' WHERE om_lettretype = 19;
1911
1912 UPDATE om_lettretype SET om_sql = 'select
1913 dossier,dossier_autorisation_type_detaille.libelle as nature,
1914 demandeur_civilite,demandeur_nom,demandeur_societe,
1915 demandeur_adresse,demandeur_cp,demandeur_ville,
1916 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1917 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
1918 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1919 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet,
1920 travaux.libelle as travaux, temp1
1921 from &DB_PREFIXEdossier
1922 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1923 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1924 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1925 where dossier = ''&destinataire''' WHERE om_lettretype = 20;
1926
1927 UPDATE om_lettretype SET om_sql = 'select
1928 dossier,dossier_autorisation_type_detaille.libelle as nature,
1929 demandeur_civilite,demandeur_nom,demandeur_societe,
1930 demandeur_adresse,demandeur_cp,demandeur_ville,
1931 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1932 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1933 concat(substring(date_depot,9,2),''/'',substring(date_depot,6,2),''/'',substring(date_depot,1,4)) as date_depot, concat(substring(date_notification_delai,9,2),''/'',substring(date_notification_delai,6,2),''/'',substring(date_notification_delai,1,4)) as date_notification_delai,
1934 concat(substring(date_limite,9,2),''/'',substring(date_limite,6,2),''/'',substring(date_limite,1,4)) as date_limite,
1935 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email,om_utilisateur.telephone
1936 from &DB_PREFIXEdossier
1937 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1938 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1939 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1940 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1941 where dossier = ''&destinataire''' WHERE om_lettretype = 21;
1942
1943 UPDATE om_lettretype SET om_sql = 'select
1944 dossier,dossier_autorisation_type_detaille.libelle as nature,
1945 demandeur_civilite,demandeur_nom,demandeur_societe,
1946 demandeur_adresse,demandeur_cp,demandeur_ville,
1947 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1948 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
1949 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1950 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet,
1951 travaux.libelle as travaux, temp1
1952 from &DB_PREFIXEdossier
1953 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1954 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1955 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1956 where dossier = ''&destinataire''' WHERE om_lettretype = 22;
1957
1958 UPDATE om_lettretype SET om_sql = 'select
1959 dossier,dossier_autorisation_type_detaille.libelle as nature,
1960 demandeur_civilite,demandeur_nom,demandeur_societe,
1961 demandeur_adresse,demandeur_cp,demandeur_ville,
1962 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1963 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1964 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1965 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1966 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1967 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
1968 from &DB_PREFIXEdossier
1969 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1970 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1971 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1972 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1973 where dossier = ''&destinataire''' WHERE om_lettretype = 23;
1974
1975 UPDATE om_lettretype SET om_sql = 'select
1976 dossier,dossier_autorisation_type_detaille.libelle as nature,
1977 demandeur_civilite,demandeur_nom,demandeur_societe,
1978 demandeur_adresse,demandeur_cp,demandeur_ville,
1979 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1980 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1981 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1982 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
1983 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
1984 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
1985 from &DB_PREFIXEdossier
1986 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1987 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
1988 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
1989 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
1990 where dossier = ''&destinataire''' WHERE om_lettretype = 24;
1991
1992 UPDATE om_lettretype SET om_sql = 'select
1993 dossier,dossier_autorisation_type_detaille.libelle as nature,
1994 demandeur_civilite,demandeur_nom,demandeur_societe,
1995 demandeur_adresse,demandeur_cp,demandeur_ville,
1996 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
1997 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
1998 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
1999 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2000 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2001 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email,om_utilisateur.telephone
2002 from &DB_PREFIXEdossier
2003 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2004 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2005 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2006 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2007 where dossier = ''&destinataire''' WHERE om_lettretype = 26;
2008
2009 UPDATE om_lettretype SET om_sql = 'select
2010 dossier,dossier_autorisation_type_detaille.libelle as nature,
2011 demandeur_civilite,demandeur_nom,demandeur_societe,
2012 demandeur_adresse,demandeur_cp,demandeur_ville,
2013 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2014 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2015 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2016 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2017 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2018 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2019 from &DB_PREFIXEdossier
2020 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2021 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2022 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2023 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2024 where dossier = ''&destinataire''' WHERE om_lettretype = 27;
2025
2026 UPDATE om_lettretype SET om_sql = 'select
2027 dossier,dossier_autorisation_type_detaille.libelle as nature,
2028 demandeur_civilite,demandeur_nom,demandeur_societe,
2029 demandeur_adresse,demandeur_cp,demandeur_ville,
2030 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2031 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2032 concat(substring(date_depot,9,2),''/'',substring(date_depot,6,2),''/'',substring(date_depot,1,4)) as date_depot, concat(substring(date_notification_delai,9,2),''/'',substring(date_notification_delai,6,2),''/'',substring(date_notification_delai,1,4)) as date_notification_delai,
2033 concat(substring(date_limite,9,2),''/'',substring(date_limite,6,2),''/'',substring(date_limite,1,4)) as date_limite,
2034 concat(substring(date_decision,9,2),''/'',substring(date_decision,6,2),''/'',substring(date_decision,1,4)) as date_decision,
2035 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2036 from &DB_PREFIXEdossier
2037 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2038 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2039 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2040 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2041 where dossier = ''&destinataire''' WHERE om_lettretype = 28;
2042
2043 UPDATE om_lettretype SET om_sql = 'select
2044 dossier,dossier_autorisation_type_detaille.libelle as nature,
2045 demandeur_civilite,demandeur_nom,demandeur_societe,
2046 demandeur_adresse,demandeur_cp,demandeur_ville,
2047 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2048 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2049 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2050 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2051 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2052 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2053 from &DB_PREFIXEdossier
2054 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2055 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2056 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2057 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2058 where dossier = ''&destinataire''' WHERE om_lettretype = 29;
2059
2060 UPDATE om_lettretype SET om_sql = 'select
2061 dossier,dossier_autorisation_type_detaille.libelle as nature,
2062 demandeur_civilite,demandeur_nom,demandeur_societe,
2063 demandeur_adresse,demandeur_cp,demandeur_ville,
2064 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2065 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
2066 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2067 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2068 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2069 travaux.libelle as travaux
2070 from &DB_PREFIXEdossier
2071 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2072 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2073 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2074 where dossier = ''&destinataire''' WHERE om_lettretype = 30;
2075
2076 UPDATE om_lettretype SET om_sql = 'select
2077 dossier,dossier_autorisation_type_detaille.libelle as nature,
2078 demandeur_civilite,demandeur_nom,demandeur_societe,
2079 demandeur_adresse,demandeur_cp,demandeur_ville,
2080 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2081 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2082 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2083 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2084 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2085 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2086 from &DB_PREFIXEdossier
2087 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2088 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2089 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2090 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2091 where dossier = ''&destinataire''' WHERE om_lettretype = 31;
2092
2093 UPDATE om_lettretype SET om_sql = 'select
2094 dossier,dossier_autorisation_type_detaille.libelle as nature,
2095 demandeur_civilite,demandeur_nom,demandeur_societe,
2096 demandeur_adresse,demandeur_cp,demandeur_ville,
2097 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2098 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2099 concat(substring(date_depot,9,2),''/'',substring(date_depot,6,2),''/'',substring(date_depot,1,4)) as date_depot, concat(substring(date_notification_delai,9,2),''/'',substring(date_notification_delai,6,2),''/'',substring(date_notification_delai,1,4)) as date_notification_delai,
2100 concat(substring(date_limite,9,2),''/'',substring(date_limite,6,2),''/'',substring(date_limite,1,4)) as date_limite,
2101 concat(substring(date_complet,9,2),''/'',substring(date_complet,6,2),''/'',substring(date_complet,1,4)) as date_complet,
2102 travaux.libelle as travaux
2103 from &DB_PREFIXEdossier
2104 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2105 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2106 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2107 where dossier = ''&destinataire''' WHERE om_lettretype = 32;
2108
2109 UPDATE om_lettretype SET om_sql = 'select
2110 dossier,dossier_autorisation_type_detaille.libelle as nature,
2111 demandeur_civilite,demandeur_nom,demandeur_societe,
2112 demandeur_adresse,demandeur_cp,demandeur_ville,
2113 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2114 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2115 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2116 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2117 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2118 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2119 from &DB_PREFIXEdossier
2120 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2121 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2122 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2123 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2124 where dossier = ''&destinataire''' WHERE om_lettretype = 33;
2125
2126 UPDATE om_lettretype SET om_sql = 'select
2127 dossier,dossier_autorisation_type_detaille.libelle as nature,
2128 demandeur_civilite,demandeur_nom,demandeur_societe,
2129 demandeur_adresse,demandeur_cp,demandeur_ville,
2130 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2131 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2132 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2133 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2134 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2135 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2136 from &DB_PREFIXEdossier
2137 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2138 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2139 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2140 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2141 where dossier = ''&destinataire''' WHERE om_lettretype = 34;
2142
2143 UPDATE om_lettretype SET om_sql = 'select
2144 dossier,dossier_autorisation_type_detaille.libelle as nature,
2145 demandeur_civilite,demandeur_nom,demandeur_societe,
2146 demandeur_adresse,demandeur_cp,demandeur_ville,
2147 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2148 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2149 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2150 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2151 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2152 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2153 from &DB_PREFIXEdossier
2154 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2155 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2156 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2157 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2158 where dossier = ''&destinataire''' WHERE om_lettretype = 35;
2159
2160 UPDATE om_lettretype SET om_sql = 'select
2161 dossier,dossier_autorisation_type_detaille.libelle as nature,
2162 demandeur_civilite,demandeur_nom,demandeur_societe,
2163 demandeur_adresse,demandeur_cp,demandeur_ville,
2164 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2165 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
2166 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2167 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2168 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2169 travaux.libelle as travaux
2170 from &DB_PREFIXEdossier
2171 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2172 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2173 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2174 where dossier = ''&destinataire''' WHERE om_lettretype = 36;
2175
2176 UPDATE om_lettretype SET om_sql = 'select
2177 dossier,dossier_autorisation_type_detaille.libelle as nature,
2178 demandeur_civilite,demandeur_nom,demandeur_societe,
2179 demandeur_adresse,demandeur_cp,demandeur_ville,
2180 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2181 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2182 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2183 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2184 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2185 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2186 from &DB_PREFIXEdossier
2187 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2188 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2189 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2190 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2191 where dossier = ''&destinataire''' WHERE om_lettretype = 37;
2192
2193 UPDATE om_lettretype SET om_sql = 'select
2194 dossier,dossier_autorisation_type_detaille.libelle as nature,
2195 demandeur_civilite,demandeur_nom,demandeur_societe,
2196 demandeur_adresse,demandeur_cp,demandeur_ville,
2197 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2198 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2199 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2200 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2201 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2202 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2203 from &DB_PREFIXEdossier
2204 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2205 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2206 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2207 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2208 where dossier = ''&destinataire''' WHERE om_lettretype = 38;
2209
2210 UPDATE om_lettretype SET om_sql = 'select
2211 dossier,dossier_autorisation_type_detaille.libelle as nature,
2212 demandeur_civilite,demandeur_nom,demandeur_societe,
2213 demandeur_adresse,demandeur_cp,demandeur_ville,
2214 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2215 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
2216 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2217 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet,
2218 travaux.libelle as travaux, temp1
2219 from &DB_PREFIXEdossier
2220 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2221 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2222 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2223 where dossier = ''&destinataire''' WHERE om_lettretype = 39;
2224
2225 UPDATE om_lettretype SET om_sql = 'select
2226 dossier,dossier_autorisation_type_detaille.libelle as nature,
2227 demandeur_civilite,demandeur_nom,demandeur_societe,
2228 demandeur_adresse,demandeur_cp,demandeur_ville,
2229 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2230 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,delai,
2231 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2232 to_char(date_notification_delai,''DD/MM/YYYY'') as date_notification_delai,
2233 to_char(date_limite,''DD/MM/YYYY'') as date_limite,
2234 travaux.libelle as travaux, om_utilisateur.nom, om_utilisateur.email, om_utilisateur.telephone
2235 from &DB_PREFIXEdossier
2236 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2237 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2238 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2239 left join &DB_PREFIXEom_utilisateur on dossier.instructeur=om_utilisateur.om_utilisateur
2240 where dossier = ''&destinataire''' WHERE om_lettretype = 40;
2241
2242 UPDATE om_lettretype SET om_sql = 'select
2243 dossier,dossier_autorisation_type_detaille.libelle as nature,
2244 demandeur_civilite,demandeur_nom,demandeur_societe,
2245 demandeur_adresse,demandeur_cp,demandeur_ville,
2246 terrain_numero, terrain_adresse, terrain_cp, terrain_ville,
2247 terrain_surface, hauteur, shon, shob, batiment_nombre, logement_nombre,
2248 to_char(date_depot,''DD/MM/YYYY'') as date_depot,
2249 to_char(date_rejet,''DD/MM/YYYY'') as date_rejet,
2250 travaux.libelle as travaux
2251 from &DB_PREFIXEdossier
2252 inner join &DB_PREFIXEdossier_autorisation on dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
2253 inner join &DB_PREFIXEdossier_autorisation_type_detaille on dossier_autorisation_type_detaille.dossier_autorisation_type_detaille=dossier_autorisation.dossier_autorisation_type_detaille
2254 left join &DB_PREFIXEtravaux on dossier.travaux=travaux.travaux
2255 where dossier = ''&destinataire''' WHERE om_lettretype = 41;
2256
2257 UPDATE om_sousetat SET om_sql = 'SELECT evenement.libelle as evenement,
2258 instruction.lettretype,
2259 to_char(date_evenement,''DD/MM/YYYY'') as datecourrier
2260 from &DB_PREFIXEinstruction
2261 inner join &DB_PREFIXEevenement on evenement.evenement = instruction.evenement
2262 where dossier = ''&idx''' WHERE om_sousetat = 2;
2263
2264 UPDATE om_sousetat SET om_sql = 'select
2265 blocnote,note,dossier
2266 from &DB_PREFIXEblocnote where
2267 dossier = ''&idx''' WHERE om_sousetat = 3;
2268
2269 UPDATE om_sousetat SET om_sql = 'SELECT
2270 destination_shon as no,destination.libelle,shon
2271 from &DB_PREFIXEdestination_shon
2272 inner join &DB_PREFIXEdestination on destination_shon.destination=destination.destination
2273 where dossier = ''&idx''' WHERE om_sousetat = 4;
2274
2275 UPDATE om_sousetat SET om_sql = 'select
2276 dossier||'' ''||types||'' du ''||to_char(date_demande,''DD/MM/YYYY'') as demande,
2277 demandeur_nom,etat
2278 from &DB_PREFIXEdossier
2279 where substring(dossier,1,9) like substring(''&idx'',1,9)'
2280 WHERE om_sousetat = 5;
2281
2282 UPDATE om_sousetat SET om_sql = 'select
2283 service.libelle||'' ''||to_char(date_envoi,''DD/MM/YYYY'') as envoi,
2284 avis_consultation.libelle||'' du ''||to_char(date_retour,''DD/MM/YYYY'') as retour,
2285 to_char(date_limite,''DD/MM/YYYY'') as limite
2286 from &DB_PREFIXEconsultation inner join &DB_PREFIXEservice on service.service = consultation.service
2287 left join &DB_PREFIXEavis_consultation on avis_consultation.avis_consultation=consultation.avis_consultation
2288 where consultation.dossier = ''&idx'''
2289 WHERE om_sousetat = 6;
2290
2291 UPDATE om_sousetat SET om_sql = 'SELECT terrain.parcelle,
2292 proprietaire.nom||'' ''|| proprietaire.prenom as proprietaire,
2293 parcelle.surface
2294 from &DB_PREFIXEterrain inner join &DB_PREFIXEparcelle on terrain.parcelle = parcelle.parcelle
2295 left join &DB_PREFIXEproprietaire on proprietaire.proprietaire = parcelle.proprietaire
2296 where dossier = ''&idx'''
2297 WHERE om_sousetat = 7;
2298
2299 ---
2300 --- Fin de suppression de la table nature
2301 ---
2302
2303
2304 -- Modification de la table evenement
2305 ALTER TABLE ONLY evenement ADD COLUMN restriction character varying(60);
2306 ALTER TABLE ONLY evenement ADD COLUMN type character varying(100);
2307 ALTER TABLE ONLY evenement ADD COLUMN evenement_retour_ar integer;
2308 ALTER TABLE ONLY evenement ADD COLUMN evenement_suivant_tacite integer;
2309
2310 ALTER TABLE ONLY evenement
2311 ADD CONSTRAINT evenement_evenement_retour_ar_fkey FOREIGN KEY (evenement_retour_ar) REFERENCES evenement(evenement);
2312 ALTER TABLE ONLY evenement
2313 ADD CONSTRAINT evenement_evenement_suivant_tacite_fkey FOREIGN KEY (evenement_suivant_tacite) REFERENCES evenement(evenement);
2314
2315 -- Modification de la table instruction
2316 ALTER TABLE instruction ADD COLUMN date_finalisation_courrier date;
2317 ALTER TABLE instruction ADD COLUMN date_envoi_signature date;
2318 ALTER TABLE instruction ADD COLUMN date_retour_signature date;
2319 ALTER TABLE instruction ADD COLUMN date_envoi_rar date;
2320 ALTER TABLE instruction ADD COLUMN date_retour_rar date;
2321 ALTER TABLE instruction ADD COLUMN date_envoi_controle_legalite date;
2322 ALTER TABLE instruction ADD COLUMN date_retour_controle_legalite date;
2323
2324 ALTER TABLE instruction RENAME COLUMN datecourrier TO date_evenement;
2325
2326 -- Mis à jour des requêtes concernant l'ancien champ datecourrier
2327 UPDATE action SET regle_date_limite='date_evenement+delai', regle_date_notification_delai='date_evenement+1', regle_date_complet='date_evenement' WHERE action = 'retour';
2328 UPDATE action SET regle_date_rejet='date_evenement' WHERE action = 'rejet';
2329 UPDATE action SET regle_date_validite='date_evenement+delai', regle_date_decision='date_evenement' WHERE action = 'acceptation';
2330 UPDATE action SET regle_date_decision='date_evenement' WHERE action = 'refus';
2331 UPDATE action SET regle_date_limite='date_evenement+delai', regle_date_validite='date_evenement+delai+2', regle_date_decision='date_evenement' WHERE action = 'sursis';
2332 UPDATE action SET regle_date_chantier='date_evenement' WHERE action = 'execution';
2333 UPDATE action SET regle_date_achevement='date_evenement' WHERE action = 'achevement';
2334 UPDATE action SET regle_date_conformite='date_evenement' WHERE action = 'archivage';
2335
2336 -- Agrandissement du champ libelle de la table om_widget
2337 ALTER TABLE om_widget ALTER COLUMN libelle TYPE character varying(100);
2338
2339 -- Gestion du rapport d'instruction
2340 CREATE TABLE rapport_instruction (
2341 rapport_instruction integer,
2342 dossier_instruction character varying(20),
2343 analyse_reglementaire text,
2344 description_projet text,
2345 proposition_decision text
2346 );
2347
2348 ALTER TABLE ONLY rapport_instruction
2349 ADD CONSTRAINT rapport_instruction_pkey PRIMARY KEY (rapport_instruction);
2350 ALTER TABLE ONLY rapport_instruction
2351 ADD CONSTRAINT rapport_instruction_dossier_instruction_fkey FOREIGN KEY (dossier_instruction) REFERENCES dossier(dossier);
2352
2353 CREATE SEQUENCE rapport_instruction_seq
2354 INCREMENT 1
2355 MINVALUE 1
2356 MAXVALUE 9223372036854775807
2357 START 1
2358 CACHE 1;
2359
2360 ALTER TABLE om_profil ADD COLUMN om_validite_debut date;
2361 ALTER TABLE om_profil ADD COLUMN om_validite_fin date;
2362
2363 -- Ajout de la colonne dossier_instruction_type dans la table dossier
2364 ALTER TABLE dossier ADD COLUMN dossier_instruction_type integer NOT NULL;
2365 ALTER TABLE ONLY dossier
2366 ADD CONSTRAINT dossier_instruction_type_dossier_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type);
2367
2368 -- Gestion des signataires
2369 CREATE TABLE signataire_arrete (
2370 signataire_arrete integer,
2371 civilite integer,
2372 nom character varying(80),
2373 prenom character varying(80),
2374 qualite character varying(80),
2375 signature text,
2376 defaut boolean,
2377 om_validite_debut date,
2378 om_validite_fin date
2379 );
2380
2381 ALTER TABLE ONLY signataire_arrete
2382 ADD CONSTRAINT signataire_arrete_pkey PRIMARY KEY (signataire_arrete);
2383 ALTER TABLE ONLY signataire_arrete
2384 ADD CONSTRAINT signataire_arrete_civilite_fkey FOREIGN KEY (civilite) REFERENCES civilite(civilite);
2385
2386 CREATE SEQUENCE signataire_arrete_seq
2387 INCREMENT 1
2388 MINVALUE 1
2389 MAXVALUE 9223372036854775807
2390 START 1
2391 CACHE 1;
2392
2393 -- FK dans la table instruction
2394 ALTER TABLE instruction ADD COLUMN signataire_arrete integer;
2395
2396 ALTER TABLE ONLY instruction
2397 ADD CONSTRAINT instruction_signataire_arrete_fkey FOREIGN KEY (signataire_arrete) REFERENCES signataire_arrete(signataire_arrete);
2398
2399 -- Modification de la structure pour l'ajout des lots
2400
2401 ALTER TABLE lot DROP COLUMN dossier_instruction;
2402 ALTER TABLE lot ADD COLUMN libelle character varying(80) NOT NULL;
2403 ALTER TABLE lot ADD COLUMN dossier_autorisation character varying(20);
2404
2405 ALTER TABLE lot ADD CONSTRAINT lot_dossier_autorisation_fkey
2406 FOREIGN KEY (dossier_autorisation) REFERENCES dossier_autorisation(dossier_autorisation);
2407
2408 CREATE TABLE lien_dossier_lot (
2409 lien_dossier_lot integer,
2410 dossier character varying(20),
2411 lot integer
2412 );
2413
2414 ALTER TABLE ONLY lien_dossier_lot
2415 ADD CONSTRAINT lien_dossier_lot_pkey PRIMARY KEY (lien_dossier_lot);
2416 ALTER TABLE ONLY lien_dossier_lot
2417 ADD CONSTRAINT lien_dossier_lot_dossier_fkey FOREIGN KEY (dossier) REFERENCES dossier(dossier);
2418 ALTER TABLE ONLY lien_dossier_lot
2419 ADD CONSTRAINT lien_dossier_lot_lot_fkey FOREIGN KEY (lot) REFERENCES lot(lot);
2420
2421 CREATE SEQUENCE lien_dossier_lot_seq
2422 INCREMENT 1
2423 MINVALUE 1
2424 MAXVALUE 9223372036854775807
2425 START 1
2426 CACHE 1;
2427
2428 ALTER TABLE demande DROP COLUMN nombre_lots;
2429
2430 -- Table CERFA
2431 CREATE TABLE cerfa (
2432 cerfa integer,
2433 libelle character varying(200),
2434 code character varying(20),
2435 om_validite_debut date,
2436 om_validite_fin date,
2437 avap_co_elt_pro boolean,
2438 avap_nouv_haut_surf boolean,
2439 avap_co_clot boolean,
2440 avap_aut_coup_aba_arb boolean,
2441 avap_ouv_infra boolean,
2442 avap_aut_inst_mob boolean,
2443 avap_aut_plant boolean,
2444 avap_aut_auv_elec boolean,
2445 tr_total boolean,
2446 tr_partiel boolean,
2447 tr_desc boolean,
2448 am_lotiss boolean,
2449 am_autre_div boolean,
2450 am_camping boolean,
2451 am_caravane boolean,
2452 am_carav_duree boolean,
2453 am_statio boolean,
2454 am_statio_cont boolean,
2455 am_affou_exhau boolean,
2456 am_affou_exhau_sup boolean,
2457 am_affou_prof boolean,
2458 am_exhau_haut boolean,
2459 am_coupe_abat boolean,
2460 am_prot_plu boolean,
2461 am_prot_muni boolean,
2462 am_mobil_voyage boolean,
2463 am_voyage_deb boolean,
2464 am_voyage_fin boolean,
2465 am_aire_voyage boolean,
2466 am_rememb_afu boolean,
2467 am_parc_resid_loi boolean,
2468 am_sport_moto boolean,
2469 am_sport_attrac boolean,
2470 am_sport_golf boolean,
2471 am_mob_art boolean,
2472 am_modif_voie_esp boolean,
2473 am_plant_voie_esp boolean,
2474 am_chem_ouv_esp boolean,
2475 am_agri_peche boolean,
2476 am_crea_voie boolean,
2477 am_modif_voie_exist boolean,
2478 am_crea_esp_sauv boolean,
2479 am_modif_amgt boolean,
2480 am_crea_esp_class boolean,
2481 am_projet_desc boolean,
2482 am_terr_surf boolean,
2483 am_tranche_desc boolean,
2484 am_lot_max_nb boolean,
2485 am_lot_max_shon boolean,
2486 am_lot_max_shob boolean,
2487 am_lot_cstr_cos boolean,
2488 am_lot_cstr_plan boolean,
2489 am_lot_cstr_vente boolean,
2490 am_lot_fin_diff boolean,
2491 am_lot_consign boolean,
2492 am_lot_gar_achev boolean,
2493 am_lot_vente_ant boolean,
2494 am_empl_nb boolean,
2495 am_tente_nb boolean,
2496 am_carav_nb boolean,
2497 am_mobil_nb boolean,
2498 am_pers_nb boolean,
2499 am_empl_hll_nb boolean,
2500 am_hll_shon boolean,
2501 am_periode_exploit boolean,
2502 am_exist_agrand boolean,
2503 am_exist_date boolean,
2504 am_exist_num boolean,
2505 am_exist_nb_avant boolean,
2506 am_exist_nb_apres boolean,
2507 am_coupe_bois boolean,
2508 am_coupe_parc boolean,
2509 am_coupe_align boolean,
2510 am_coupe_ess boolean,
2511 am_coupe_age boolean,
2512 am_coupe_dens boolean,
2513 am_coupe_qual boolean,
2514 am_coupe_trait boolean,
2515 am_coupe_autr boolean,
2516 co_archi_recours boolean,
2517 co_cstr_nouv boolean,
2518 co_cstr_exist boolean,
2519 co_modif_aspect boolean,
2520 co_modif_struct boolean,
2521 co_cloture boolean,
2522 co_ouvr_elec boolean,
2523 co_elec_tension boolean,
2524 co_ouvr_infra boolean,
2525 co_trx_imm boolean,
2526 co_div_terr boolean,
2527 co_projet_desc boolean,
2528 co_cstr_shob boolean,
2529 co_anx_pisc boolean,
2530 co_anx_gara boolean,
2531 co_anx_veran boolean,
2532 co_anx_abri boolean,
2533 co_anx_autr boolean,
2534 co_anx_autr_desc boolean,
2535 co_tot_log_nb boolean,
2536 co_tot_ind_nb boolean,
2537 co_tot_coll_nb boolean,
2538 co_mais_piece_nb boolean,
2539 co_mais_niv_nb boolean,
2540 co_fin_lls_nb boolean,
2541 co_fin_aa_nb boolean,
2542 co_fin_ptz_nb boolean,
2543 co_fin_autr_nb boolean,
2544 co_fin_autr_desc boolean,
2545 co_finan1_id boolean,
2546 co_finan1_nb boolean,
2547 co_finan2_id boolean,
2548 co_finan2_nb boolean,
2549 co_finan3_id boolean,
2550 co_finan3_nb boolean,
2551 co_finan4_id boolean,
2552 co_finan4_nb boolean,
2553 co_finan5_id boolean,
2554 co_finan5_nb boolean,
2555 co_mais_contrat_ind boolean,
2556 co_uti_pers boolean,
2557 co_uti_vente boolean,
2558 co_uti_loc boolean,
2559 co_uti_princ boolean,
2560 co_uti_secon boolean,
2561 co_resid_agees boolean,
2562 co_resid_etud boolean,
2563 co_resid_tourism boolean,
2564 co_resid_hot_soc boolean,
2565 co_resid_soc boolean,
2566 co_resid_hand boolean,
2567 co_resid_autr boolean,
2568 co_resid_autr_desc boolean,
2569 co_foyer_chamb_nb boolean,
2570 co_log_1p_nb boolean,
2571 co_log_2p_nb boolean,
2572 co_log_3p_nb boolean,
2573 co_log_4p_nb boolean,
2574 co_log_5p_nb boolean,
2575 co_log_6p_nb boolean,
2576 co_bat_niv_nb boolean,
2577 co_trx_exten boolean,
2578 co_trx_surelev boolean,
2579 co_trx_nivsup boolean,
2580 co_trx_amgt boolean,
2581 co_demont_periode boolean,
2582 co_sp_transport boolean,
2583 co_sp_enseign boolean,
2584 co_sp_act_soc boolean,
2585 co_sp_ouvr_spe boolean,
2586 co_sp_sante boolean,
2587 co_sp_culture boolean,
2588 co_statio_avt_nb boolean,
2589 co_statio_apr_nb boolean,
2590 co_statio_avt_shob boolean,
2591 co_statio_apr_shob boolean,
2592 co_statio_avt_surf boolean,
2593 co_statio_apr_surf boolean,
2594 co_statio_adr boolean,
2595 co_statio_place_nb boolean,
2596 co_statio_tot_surf boolean,
2597 co_statio_tot_shob boolean,
2598 co_statio_comm_cin_surf boolean,
2599 tab_surface integer,
2600 dm_constr_dates boolean,
2601 dm_total boolean,
2602 dm_partiel boolean,
2603 dm_projet_desc boolean,
2604 dm_tot_log_nb boolean,
2605 tax_surf_tot boolean,
2606 tax_surf boolean,
2607 tax_surf_suppr_mod boolean,
2608 tax_dest_loc_tr boolean,
2609 tab_tax_su_princ integer,
2610 tab_tax_su_heber integer,
2611 tab_tax_su_secon integer,
2612 tab_tax_su_tot integer,
2613
2614 tax_ext_pret boolean,
2615 tax_ext_desc boolean,
2616 tax_surf_tax_exist_cons boolean,
2617 tax_log_exist_nb boolean,
2618
2619
2620 tax_trx_presc_ppr boolean,
2621 tax_monu_hist boolean,
2622 tax_comm_nb boolean,
2623 tab_tax_su_non_habit_surf integer,
2624 tab_tax_am integer,
2625
2626 vsd_surf_planch_smd boolean,
2627 vsd_unit_fonc_sup boolean,
2628 vsd_unit_fonc_constr_sup boolean,
2629 vsd_val_terr boolean,
2630 vsd_const_sxist_non_dem_surf boolean,
2631 vsd_rescr_fisc boolean,
2632
2633 pld_val_terr boolean,
2634 pld_const_exist_dem boolean,
2635 pld_const_exist_dem_surf boolean,
2636
2637 code_cnil boolean
2638 );
2639
2640 ALTER TABLE ONLY cerfa
2641 ADD CONSTRAINT cerfa_pkey PRIMARY KEY (cerfa);
2642
2643 CREATE SEQUENCE cerfa_seq
2644 INCREMENT 1
2645 MINVALUE 1
2646 MAXVALUE 9223372036854775807
2647 START 1
2648 CACHE 1;
2649
2650 ALTER TABLE ONLY dossier_instruction_type
2651 ADD CONSTRAINT dossier_instruction_type_cerfa_fkey
2652 FOREIGN KEY (cerfa) REFERENCES cerfa(cerfa);
2653
2654 ALTER TABLE ONLY dossier_instruction_type
2655 ADD CONSTRAINT dossier_instruction_type_cerfa_lot_fkey
2656 FOREIGN KEY (cerfa_lot) REFERENCES cerfa(cerfa);
2657
2658 -- Table donnees_techniques
2659 CREATE TABLE donnees_techniques (
2660 donnees_techniques integer,
2661 dossier_instruction character varying(20),
2662 lot integer,
2663 avap_co_elt_pro boolean,
2664 avap_nouv_haut_surf boolean,
2665 avap_co_clot boolean,
2666 avap_aut_coup_aba_arb boolean,
2667 avap_ouv_infra boolean,
2668 avap_aut_inst_mob boolean,
2669 avap_aut_plant boolean,
2670 avap_aut_auv_elec boolean,
2671 tr_total boolean,
2672 tr_partiel boolean,
2673 tr_desc text,
2674 am_lotiss boolean,
2675 am_autre_div boolean,
2676 am_camping boolean,
2677 am_caravane boolean,
2678 am_carav_duree integer,
2679 am_statio boolean,
2680 am_statio_cont integer,
2681 am_affou_exhau boolean,
2682 am_affou_exhau_sup numeric,
2683 am_affou_prof numeric,
2684 am_exhau_haut numeric,
2685 am_coupe_abat boolean,
2686 am_prot_plu boolean,
2687 am_prot_muni boolean,
2688 am_mobil_voyage boolean,
2689 am_voyage_deb date,
2690 am_voyage_fin date,
2691 am_aire_voyage boolean,
2692 am_rememb_afu boolean,
2693 am_parc_resid_loi boolean,
2694 am_sport_moto boolean,
2695 am_sport_attrac boolean,
2696 am_sport_golf boolean,
2697 am_mob_art boolean,
2698 am_modif_voie_esp boolean,
2699 am_plant_voie_esp boolean,
2700 am_chem_ouv_esp boolean,
2701 am_agri_peche boolean,
2702 am_crea_voie boolean,
2703 am_modif_voie_exist boolean,
2704 am_crea_esp_sauv boolean,
2705 am_modif_amgt boolean,
2706 am_crea_esp_class boolean,
2707 am_projet_desc text,
2708 am_terr_surf numeric,
2709 am_tranche_desc text,
2710 am_lot_max_nb integer,
2711 am_lot_max_shon numeric,
2712 am_lot_max_shob numeric,
2713 am_lot_cstr_cos boolean,
2714 am_lot_cstr_plan boolean,
2715 am_lot_cstr_vente boolean,
2716 am_lot_fin_diff boolean,
2717 am_lot_consign boolean,
2718 am_lot_gar_achev boolean,
2719 am_lot_vente_ant boolean,
2720 am_empl_nb integer,
2721 am_tente_nb integer,
2722 am_carav_nb integer,
2723 am_mobil_nb integer,
2724 am_pers_nb integer,
2725 am_empl_hll_nb integer,
2726 am_hll_shon numeric,
2727 am_periode_exploit text,
2728 am_exist_agrand boolean,
2729 am_exist_date date,
2730 am_exist_num character varying(100),
2731 am_exist_nb_avant integer,
2732 am_exist_nb_apres integer,
2733 am_coupe_bois boolean,
2734 am_coupe_parc boolean,
2735 am_coupe_align boolean,
2736 am_coupe_ess character varying(100),
2737 am_coupe_age character varying(15),
2738 am_coupe_dens character varying(100),
2739 am_coupe_qual character varying(100),
2740 am_coupe_trait character varying(100),
2741 am_coupe_autr character varying(100),
2742 co_archi_recours boolean,
2743 co_cstr_nouv boolean,
2744 co_cstr_exist boolean,
2745 co_modif_aspect boolean,
2746 co_modif_struct boolean,
2747 co_cloture boolean,
2748 co_ouvr_elec boolean,
2749 co_elec_tension numeric,
2750 co_ouvr_infra boolean,
2751 co_trx_imm boolean,
2752 co_div_terr boolean,
2753 co_projet_desc text,
2754 co_cstr_shob numeric,
2755 co_anx_pisc boolean,
2756 co_anx_gara boolean,
2757 co_anx_veran boolean,
2758 co_anx_abri boolean,
2759 co_anx_autr boolean,
2760 co_anx_autr_desc text,
2761 co_tot_log_nb integer,
2762 co_tot_ind_nb integer,
2763 co_tot_coll_nb integer,
2764 co_mais_piece_nb integer,
2765 co_mais_niv_nb integer,
2766 co_fin_lls_nb integer,
2767 co_fin_aa_nb integer,
2768 co_fin_ptz_nb integer,
2769 co_fin_autr_nb integer,
2770 co_fin_autr_desc text,
2771 co_finan1_id integer,
2772 co_finan1_nb integer,
2773 co_finan2_id integer,
2774 co_finan2_nb integer,
2775 co_finan3_id integer,
2776 co_finan3_nb integer,
2777 co_finan4_id integer,
2778 co_finan4_nb integer,
2779 co_finan5_id integer,
2780 co_finan5_nb integer,
2781 co_mais_contrat_ind boolean,
2782 co_uti_pers boolean,
2783 co_uti_vente boolean,
2784 co_uti_loc boolean,
2785 co_uti_princ boolean,
2786 co_uti_secon boolean,
2787 co_resid_agees boolean,
2788 co_resid_etud boolean,
2789 co_resid_tourism boolean,
2790 co_resid_hot_soc boolean,
2791 co_resid_soc boolean,
2792 co_resid_hand boolean,
2793 co_resid_autr boolean,
2794 co_resid_autr_desc text,
2795 co_foyer_chamb_nb integer,
2796 co_log_1p_nb integer,
2797 co_log_2p_nb integer,
2798 co_log_3p_nb integer,
2799 co_log_4p_nb integer,
2800 co_log_5p_nb integer,
2801 co_log_6p_nb integer,
2802 co_bat_niv_nb integer,
2803 co_trx_exten boolean,
2804 co_trx_surelev boolean,
2805 co_trx_nivsup boolean,
2806 co_trx_amgt boolean,
2807 co_demont_periode text,
2808 co_sp_transport boolean,
2809 co_sp_enseign boolean,
2810 co_sp_act_soc boolean,
2811 co_sp_ouvr_spe boolean,
2812 co_sp_sante boolean,
2813 co_sp_culture boolean,
2814 co_statio_avt_nb integer,
2815 co_statio_apr_nb integer,
2816 co_statio_avt_shob numeric,
2817 co_statio_apr_shob numeric,
2818 co_statio_avt_surf numeric,
2819 co_statio_apr_surf numeric,
2820 co_statio_adr text,
2821 co_statio_place_nb integer,
2822 co_statio_tot_surf numeric,
2823 co_statio_tot_shob numeric,
2824 co_statio_comm_cin_surf numeric,
2825 su_avt_shon1 numeric,
2826 su_avt_shon2 numeric,
2827 su_avt_shon3 numeric,
2828 su_avt_shon4 numeric,
2829 su_avt_shon5 numeric,
2830 su_avt_shon6 numeric,
2831 su_avt_shon7 numeric,
2832 su_avt_shon8 numeric,
2833 su_avt_shon9 numeric,
2834 su_cstr_shon1 numeric,
2835 su_cstr_shon2 numeric,
2836 su_cstr_shon3 numeric,
2837 su_cstr_shon4 numeric,
2838 su_cstr_shon5 numeric,
2839 su_cstr_shon6 numeric,
2840 su_cstr_shon7 numeric,
2841 su_cstr_shon8 numeric,
2842 su_cstr_shon9 numeric,
2843 su_trsf_shon1 numeric,
2844 su_trsf_shon2 numeric,
2845 su_trsf_shon3 numeric,
2846 su_trsf_shon4 numeric,
2847 su_trsf_shon5 numeric,
2848 su_trsf_shon6 numeric,
2849 su_trsf_shon7 numeric,
2850 su_trsf_shon8 numeric,
2851 su_trsf_shon9 numeric,
2852 su_chge_shon1 numeric,
2853 su_chge_shon2 numeric,
2854 su_chge_shon3 numeric,
2855 su_chge_shon4 numeric,
2856 su_chge_shon5 numeric,
2857 su_chge_shon6 numeric,
2858 su_chge_shon7 numeric,
2859 su_chge_shon8 numeric,
2860 su_chge_shon9 numeric,
2861 su_demo_shon1 numeric,
2862 su_demo_shon2 numeric,
2863 su_demo_shon3 numeric,
2864 su_demo_shon4 numeric,
2865 su_demo_shon5 numeric,
2866 su_demo_shon6 numeric,
2867 su_demo_shon7 numeric,
2868 su_demo_shon8 numeric,
2869 su_demo_shon9 numeric,
2870 su_sup_shon1 numeric,
2871 su_sup_shon2 numeric,
2872 su_sup_shon3 numeric,
2873 su_sup_shon4 numeric,
2874 su_sup_shon5 numeric,
2875 su_sup_shon6 numeric,
2876 su_sup_shon7 numeric,
2877 su_sup_shon8 numeric,
2878 su_sup_shon9 numeric,
2879 su_tot_shon1 numeric,
2880 su_tot_shon2 numeric,
2881 su_tot_shon3 numeric,
2882 su_tot_shon4 numeric,
2883 su_tot_shon5 numeric,
2884 su_tot_shon6 numeric,
2885 su_tot_shon7 numeric,
2886 su_tot_shon8 numeric,
2887 su_tot_shon9 numeric,
2888 su_avt_shon_tot numeric,
2889 su_cstr_shon_tot numeric,
2890 su_trsf_shon_tot numeric,
2891 su_chge_shon_tot numeric,
2892 su_demo_shon_tot numeric,
2893 su_sup_shon_tot numeric,
2894 su_tot_shon_tot numeric,
2895 dm_constr_dates text,
2896 dm_total boolean,
2897 dm_partiel boolean,
2898 dm_projet_desc text,
2899 dm_tot_log_nb integer,
2900 tax_surf_tot numeric,
2901 tax_surf numeric,
2902 tax_surf_suppr_mod numeric,
2903 tax_dest_loc_tr text,
2904
2905 tax_su_princ_log_nb1 numeric,
2906 tax_su_princ_log_nb2 numeric,
2907 tax_su_princ_log_nb3 numeric,
2908 tax_su_princ_log_nb4 numeric,
2909 tax_su_princ_log_nb_tot1 numeric,
2910 tax_su_princ_log_nb_tot2 numeric,
2911 tax_su_princ_log_nb_tot3 numeric,
2912 tax_su_princ_log_nb_tot4 numeric,
2913 tax_su_princ_surf1 numeric,
2914 tax_su_princ_surf2 numeric,
2915 tax_su_princ_surf3 numeric,
2916 tax_su_princ_surf4 numeric,
2917 tax_su_princ_surf_sup1 numeric,
2918 tax_su_princ_surf_sup2 numeric,
2919 tax_su_princ_surf_sup3 numeric,
2920 tax_su_princ_surf_sup4 numeric,
2921
2922 tax_su_heber_log_nb1 integer,
2923 tax_su_heber_log_nb2 integer,
2924 tax_su_heber_log_nb3 integer,
2925 tax_su_heber_log_nb_tot1 integer,
2926 tax_su_heber_log_nb_tot2 integer,
2927 tax_su_heber_log_nb_tot3 integer,
2928 tax_su_heber_surf1 numeric,
2929 tax_su_heber_surf2 numeric,
2930 tax_su_heber_surf3 numeric,
2931 tax_su_heber_surf_sup1 numeric,
2932 tax_su_heber_surf_sup2 numeric,
2933 tax_su_heber_surf_sup3 numeric,
2934
2935 tax_su_secon_log_nb integer,
2936 tax_su_tot_log_nb integer,
2937 tax_su_secon_log_nb_tot integer,
2938 tax_su_tot_log_nb_tot integer,
2939 tax_su_secon_surf numeric,
2940 tax_su_tot_surf numeric,
2941 tax_su_secon_surf_sup numeric,
2942 tax_su_tot_surf_sup numeric,
2943
2944 tax_ext_pret boolean,
2945 tax_ext_desc text,
2946 tax_surf_tax_exist_cons numeric,
2947 tax_log_exist_nb integer,
2948
2949 tax_am_statio_ext integer,
2950 tax_sup_bass_pisc numeric,
2951 tax_empl_ten_carav_mobil_nb integer,
2952 tax_empl_hll_nb integer,
2953 tax_eol_haut_nb integer,
2954 tax_pann_volt_sup numeric,
2955
2956 tax_am_statio_ext_sup integer,
2957 tax_sup_bass_pisc_sup numeric,
2958 tax_empl_ten_carav_mobil_nb_sup integer,
2959 tax_empl_hll_nb_sup integer,
2960 tax_eol_haut_nb_sup integer,
2961 tax_pann_volt_sup_sup numeric,
2962
2963 tax_trx_presc_ppr boolean,
2964 tax_monu_hist boolean,
2965
2966 tax_comm_nb integer,
2967
2968 tax_su_non_habit_surf1 numeric,
2969 tax_su_non_habit_surf2 numeric,
2970 tax_su_non_habit_surf3 numeric,
2971 tax_su_non_habit_surf4 numeric,
2972 tax_su_non_habit_surf5 numeric,
2973 tax_su_non_habit_surf6 numeric,
2974 tax_su_non_habit_surf7 numeric,
2975 tax_su_non_habit_surf_sup1 numeric,
2976 tax_su_non_habit_surf_sup2 numeric,
2977 tax_su_non_habit_surf_sup3 numeric,
2978 tax_su_non_habit_surf_sup4 numeric,
2979 tax_su_non_habit_surf_sup5 numeric,
2980 tax_su_non_habit_surf_sup6 numeric,
2981 tax_su_non_habit_surf_sup7 numeric,
2982
2983 vsd_surf_planch_smd boolean,
2984 vsd_unit_fonc_sup numeric,
2985 vsd_unit_fonc_constr_sup numeric,
2986 vsd_val_terr numeric,
2987 vsd_const_sxist_non_dem_surf numeric,
2988 vsd_rescr_fisc date,
2989
2990 pld_val_terr numeric,
2991 pld_const_exist_dem boolean,
2992 pld_const_exist_dem_surf numeric,
2993
2994 code_cnil boolean
2995 );
2996
2997 ALTER TABLE ONLY donnees_techniques
2998 ADD CONSTRAINT donnees_techniques_pkey PRIMARY KEY (donnees_techniques);
2999 ALTER TABLE ONLY donnees_techniques
3000 ADD CONSTRAINT donnees_techniques_dossier_instruction_fkey FOREIGN KEY (dossier_instruction) REFERENCES dossier(dossier);
3001 ALTER TABLE ONLY donnees_techniques
3002 ADD CONSTRAINT donnees_techniques_lot_fkey FOREIGN KEY (lot) REFERENCES lot(lot);
3003
3004 CREATE SEQUENCE donnees_techniques_seq
3005 INCREMENT 1
3006 MINVALUE 1
3007 MAXVALUE 9223372036854775807
3008 START 1
3009 CACHE 1;
3010
3011 -- Table etat_dossier_autorisation
3012 CREATE TABLE etat_dossier_autorisation (
3013 etat_dossier_autorisation integer,
3014 libelle character varying(100)
3015 );
3016
3017 ALTER TABLE ONLY etat_dossier_autorisation
3018 ADD CONSTRAINT etat_dossier_autorisation_pkey PRIMARY KEY (etat_dossier_autorisation);
3019
3020 CREATE SEQUENCE etat_dossier_autorisation_seq
3021 INCREMENT 1
3022 MINVALUE 1
3023 MAXVALUE 9223372036854775807
3024 START 1
3025 CACHE 1;
3026
3027 ALTER TABLE dossier_autorisation DROP COLUMN etat;
3028 ALTER TABLE dossier_autorisation ADD COLUMN etat_dossier_autorisation integer;
3029
3030 ALTER TABLE ONLY dossier_autorisation
3031 ADD CONSTRAINT dossier_autorisation_etat_dossier_autorisation_fkey FOREIGN KEY (etat_dossier_autorisation) REFERENCES etat_dossier_autorisation(etat_dossier_autorisation);
3032
3033
3034 ALTER TABLE action ADD COLUMN methode_trigger character varying(250);
3035
3036 ALTER TABLE instruction ADD COLUMN numero_arrete character varying(100);
3037
3038 -- Suppression des tables Statistique et Destination_shon
3039 --Suppression des contraintes
3040 ALTER TABLE destination_shon DROP CONSTRAINT destination_shon_pkey;
3041 ALTER TABLE destination_shon DROP CONSTRAINT destination_shon_destination_fkey;
3042 ALTER TABLE destination_shon DROP CONSTRAINT destination_shon_dossier_fkey;
3043
3044 -- Suppression des données inutiles
3045 DELETE FROM om_droit WHERE om_droit = 72 ;
3046 DELETE FROM om_sousetat WHERE om_sousetat = 4 ;
3047 UPDATE om_etat SET sousetat='instruction
3048 consultation
3049 blocnote
3050 terrain'
3051 WHERE om_etat = 7;
3052
3053 -- Suppression de la séquence
3054 DROP SEQUENCE destination_shon_seq ;
3055
3056 -- Suppression de la table
3057 DROP TABLE destination_shon;
3058
3059 -- Suppression des champs de la table dossier
3060
3061 ALTER TABLE dossier DROP COLUMN demandeur_categorie;
3062 ALTER TABLE dossier DROP COLUMN demandeur_civilite;
3063 ALTER TABLE dossier DROP COLUMN demandeur_nom;
3064 ALTER TABLE dossier DROP COLUMN demandeur_societe;
3065 ALTER TABLE dossier DROP COLUMN demandeur_adresse;
3066 ALTER TABLE dossier DROP COLUMN demandeur_adresse_complement;
3067 ALTER TABLE dossier DROP COLUMN demandeur_cp;
3068 ALTER TABLE dossier DROP COLUMN demandeur_ville;
3069 ALTER TABLE dossier DROP COLUMN demandeur_pays;
3070 ALTER TABLE dossier DROP COLUMN demandeur_email;
3071 ALTER TABLE dossier DROP COLUMN demandeur_telephone;
3072 ALTER TABLE dossier DROP COLUMN delegataire;
3073 ALTER TABLE dossier DROP COLUMN delegataire_civilite;
3074 ALTER TABLE dossier DROP COLUMN delegataire_nom;
3075 ALTER TABLE dossier DROP COLUMN delegataire_societe;
3076 ALTER TABLE dossier DROP COLUMN delegataire_adresse;
3077 ALTER TABLE dossier DROP COLUMN delegataire_adresse_complement;
3078 ALTER TABLE dossier DROP COLUMN delegataire_cp;
3079 ALTER TABLE dossier DROP COLUMN delegataire_ville;
3080 ALTER TABLE dossier DROP COLUMN delegataire_pays;
3081 ALTER TABLE dossier DROP COLUMN delegataire_email;
3082 ALTER TABLE dossier DROP COLUMN delegataire_telephone;
3083 ALTER TABLE dossier DROP COLUMN architecte;
3084 ALTER TABLE dossier DROP COLUMN travaux;
3085 ALTER TABLE dossier DROP COLUMN travaux_complement;
3086 ALTER TABLE dossier DROP COLUMN terrain_numero;
3087 ALTER TABLE dossier DROP COLUMN terrain_numero_complement;
3088 ALTER TABLE dossier DROP COLUMN rivoli;
3089 ALTER TABLE dossier DROP COLUMN terrain_adresse;
3090 ALTER TABLE dossier DROP COLUMN terrain_adresse_complement;
3091 ALTER TABLE dossier DROP COLUMN terrain_cp;
3092 ALTER TABLE dossier DROP COLUMN terrain_ville;
3093 ALTER TABLE dossier DROP COLUMN terrain_surface;
3094 ALTER TABLE dossier DROP COLUMN terrain_surface_calcul;
3095
3096 -- Statistique
3097 -- Suppression de la séquence
3098 DROP SEQUENCE statistique_seq ;
3099
3100 -- Suppression de la table
3101 DROP TABLE statistique;

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26