1 |
-- |
2 |
-- Ajout de table: avis_consultation_tmp; |
3 |
-- |
4 |
|
5 |
|
6 |
CREATE TABLE avis_consultation_tmp ( |
7 |
avis character varying(2) NOT NULL, |
8 |
libelle character varying(30) NOT NULL, |
9 |
typeavis character(1) DEFAULT ''::bpchar NOT NULL, |
10 |
sitadel character(1) DEFAULT ''::bpchar NOT NULL, |
11 |
sitadel_motif character(1) DEFAULT ''::bpchar NOT NULL |
12 |
); |
13 |
|
14 |
|
15 |
-- |
16 |
-- Data for Name: avis_consultation_tmp; |
17 |
-- |
18 |
|
19 |
INSERT INTO avis_consultation_tmp VALUES ('D', 'Defavorable', 'D', '6', ' '); |
20 |
INSERT INTO avis_consultation_tmp VALUES ('F', 'Favorable', 'F', '4', ' '); |
21 |
INSERT INTO avis_consultation_tmp VALUES ('F1', 'Favorable avec Reserve', 'F', '4', ' '); |
22 |
INSERT INTO avis_consultation_tmp VALUES ('T', 'Tacite', 'F', '2', ' '); |
23 |
INSERT INTO avis_consultation_tmp VALUES ('A', 'Autre', ' ', '7', ' '); |
24 |
|
25 |
|
26 |
-- |
27 |
-- Ajout de la table 'service_categorie' |
28 |
-- |
29 |
CREATE TABLE service_categorie ( |
30 |
service_categorie integer, |
31 |
libelle varchar(70) NOT NULL default '' |
32 |
); |
33 |
|
34 |
ALTER TABLE ONLY service_categorie |
35 |
ADD CONSTRAINT service_categorie_pkey PRIMARY KEY (service_categorie); |
36 |
|
37 |
CREATE SEQUENCE service_categorie_seq |
38 |
INCREMENT 1 |
39 |
MINVALUE 1 |
40 |
MAXVALUE 9223372036854775807 |
41 |
START 1 |
42 |
CACHE 1; |
43 |
|
44 |
-- |
45 |
-- Modification de la table 'service' et des clés étangères |
46 |
-- |
47 |
ALTER TABLE consultation DROP CONSTRAINT consultation_service_fkey; |
48 |
ALTER TABLE service DROP CONSTRAINT service_pkey; |
49 |
|
50 |
ALTER TABLE consultation RENAME COLUMN service TO service_old; |
51 |
ALTER TABLE service RENAME COLUMN service TO service_old; |
52 |
|
53 |
CREATE SEQUENCE service_seq |
54 |
START WITH 1 |
55 |
INCREMENT BY 1 |
56 |
NO MAXVALUE |
57 |
NO MINVALUE |
58 |
CACHE 1; |
59 |
|
60 |
ALTER TABLE service ADD COLUMN service integer NOT NULL DEFAULT nextval('service_seq'::regclass); |
61 |
ALTER TABLE consultation ADD COLUMN service integer; |
62 |
|
63 |
UPDATE consultation SET service=(select service.service from service where service_old=service.service_old); |
64 |
|
65 |
ALTER TABLE service ADD COLUMN consultation_papier boolean; |
66 |
ALTER TABLE service ADD COLUMN notification_email boolean; |
67 |
ALTER TABLE service ADD COLUMN om_validite_debut date; |
68 |
ALTER TABLE service ADD COLUMN om_validite_fin date; |
69 |
ALTER TABLE service ADD COLUMN type_consultation varchar(70) NOT NULL DEFAULT 'avec_avis_attendu'; |
70 |
|
71 |
ALTER TABLE service RENAME COLUMN service_old TO abrege; |
72 |
ALTER TABLE consultation DROP COLUMN service_old; |
73 |
|
74 |
ALTER TABLE ONLY service |
75 |
ADD CONSTRAINT service_pkey PRIMARY KEY (service); |
76 |
|
77 |
ALTER TABLE ONLY consultation |
78 |
ADD CONSTRAINT consultation_service_fkey FOREIGN KEY (service) REFERENCES service(service); |
79 |
|
80 |
ALTER SEQUENCE service_seq OWNED BY service.service; |
81 |
|
82 |
ALTER TABLE service ALTER COLUMN service DROP DEFAULT; |
83 |
|
84 |
-- |
85 |
-- Ajout de la table 'lien_service_service_categorie' |
86 |
-- |
87 |
|
88 |
CREATE TABLE lien_service_service_categorie ( |
89 |
lien_service_service_categorie integer, |
90 |
service_categorie integer, |
91 |
service integer |
92 |
); |
93 |
|
94 |
ALTER TABLE ONLY lien_service_service_categorie |
95 |
ADD CONSTRAINT lien_service_service_categorie_pkey PRIMARY KEY (lien_service_service_categorie); |
96 |
ALTER TABLE ONLY lien_service_service_categorie |
97 |
ADD CONSTRAINT lien_service_service_categorie_service_categorie_fkey FOREIGN KEY (service_categorie) REFERENCES service_categorie(service_categorie); |
98 |
ALTER TABLE ONLY lien_service_service_categorie |
99 |
ADD CONSTRAINT lien_service_service_categorie_service_fkey FOREIGN KEY (service) REFERENCES service(service); |
100 |
|
101 |
CREATE SEQUENCE lien_service_service_categorie_seq |
102 |
INCREMENT 1 |
103 |
MINVALUE 1 |
104 |
MAXVALUE 9223372036854775807 |
105 |
START 1 |
106 |
CACHE 1; |
107 |
|
108 |
-- |
109 |
-- Ajout de la table 'lien_service_utilisateur' |
110 |
-- |
111 |
|
112 |
CREATE TABLE lien_service_om_utilisateur ( |
113 |
lien_service_om_utilisateur integer, |
114 |
om_utilisateur bigint, |
115 |
service integer |
116 |
); |
117 |
|
118 |
ALTER TABLE ONLY lien_service_om_utilisateur |
119 |
ADD CONSTRAINT lien_service_om_utilisateur_pkey PRIMARY KEY (lien_service_om_utilisateur); |
120 |
ALTER TABLE ONLY lien_service_om_utilisateur |
121 |
ADD CONSTRAINT lien_service_om_utilisateur_om_utilisateur_fkey FOREIGN KEY (om_utilisateur) REFERENCES om_utilisateur(om_utilisateur); |
122 |
ALTER TABLE ONLY lien_service_om_utilisateur |
123 |
ADD CONSTRAINT lien_service_om_utilisateur_service_fkey FOREIGN KEY (service) REFERENCES service(service); |
124 |
|
125 |
CREATE SEQUENCE lien_service_om_utilisateur_seq |
126 |
INCREMENT 1 |
127 |
MINVALUE 1 |
128 |
MAXVALUE 9223372036854775807 |
129 |
START 1 |
130 |
CACHE 1; |
131 |
|
132 |
-- |
133 |
-- Ajout des tables 'avis_consultation' et 'avis_decision' |
134 |
-- |
135 |
|
136 |
CREATE TABLE avis_decision ( |
137 |
avis_old character varying(2) NOT NULL, |
138 |
libelle character varying(30) NOT NULL, |
139 |
typeavis character(1) DEFAULT ''::bpchar NOT NULL, |
140 |
sitadel character(1) DEFAULT ''::bpchar NOT NULL, |
141 |
sitadel_motif character(1) DEFAULT ''::bpchar NOT NULL |
142 |
); |
143 |
|
144 |
CREATE SEQUENCE avis_decision_seq |
145 |
INCREMENT 1 |
146 |
MINVALUE 1 |
147 |
MAXVALUE 9223372036854775807 |
148 |
START 1 |
149 |
CACHE 1; |
150 |
|
151 |
CREATE TABLE avis_consultation ( |
152 |
avis_old character varying(2) NOT NULL, |
153 |
libelle character varying(30) NOT NULL, |
154 |
abrege character varying(10), |
155 |
om_validite_debut date, |
156 |
om_validite_fin date |
157 |
); |
158 |
|
159 |
CREATE SEQUENCE avis_consultation_seq |
160 |
INCREMENT 1 |
161 |
MINVALUE 1 |
162 |
MAXVALUE 9223372036854775807 |
163 |
START 1 |
164 |
CACHE 1; |
165 |
|
166 |
ALTER TABLE avis_decision ADD COLUMN avis_decision integer NOT NULL DEFAULT nextval('avis_decision_seq'::regclass); |
167 |
INSERT INTO avis_decision(avis_old, libelle, typeavis, sitadel, sitadel_motif) SELECT avis, libelle, typeavis, sitadel, sitadel_motif |
168 |
FROM avis; |
169 |
|
170 |
ALTER TABLE avis_consultation ADD COLUMN avis_consultation integer NOT NULL DEFAULT nextval('avis_consultation_seq'::regclass); |
171 |
INSERT INTO avis_consultation(avis_old, libelle) SELECT avis, libelle |
172 |
FROM avis_consultation_tmp; |
173 |
|
174 |
|
175 |
ALTER TABLE ONLY avis_decision |
176 |
ADD CONSTRAINT avis_decision_pkey PRIMARY KEY (avis_decision); |
177 |
ALTER TABLE ONLY avis_consultation |
178 |
ADD CONSTRAINT avis_consultation_pkey PRIMARY KEY (avis_consultation); |
179 |
ALTER SEQUENCE avis_consultation_seq OWNED BY avis_consultation.avis_consultation; |
180 |
ALTER SEQUENCE avis_decision_seq OWNED BY avis_decision.avis_decision; |
181 |
ALTER TABLE avis_decision ALTER COLUMN avis_decision DROP DEFAULT; |
182 |
ALTER TABLE avis_consultation ALTER COLUMN avis_consultation DROP DEFAULT; |
183 |
|
184 |
-- Changement des clés étrangères pour 'avis' |
185 |
ALTER TABLE consultation DROP CONSTRAINT consultation_avis_fkey; |
186 |
ALTER TABLE evenement DROP CONSTRAINT evenement_avis_fkey; |
187 |
ALTER TABLE instruction DROP CONSTRAINT instruction_avis_fkey; |
188 |
ALTER TABLE dossier DROP CONSTRAINT dossier_avis_fkey; |
189 |
|
190 |
ALTER TABLE consultation ADD COLUMN avis_consultation integer; |
191 |
ALTER TABLE evenement ADD COLUMN avis_decision integer; |
192 |
ALTER TABLE instruction ADD COLUMN avis_decision integer; |
193 |
ALTER TABLE dossier ADD COLUMN avis_decision integer; |
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
UPDATE consultation SET avis_consultation=(select avis_consultation.avis_consultation from avis_consultation where avis=avis_consultation.avis_old); |
200 |
|
201 |
-- |
202 |
-- Modification de la table 'consultation' |
203 |
-- |
204 |
ALTER TABLE consultation ADD COLUMN date_reception date; |
205 |
ALTER TABLE consultation ADD COLUMN motivation text DEFAULT ''; |
206 |
ALTER TABLE consultation ADD COLUMN fichier character varying(100); |
207 |
ALTER TABLE consultation ADD COLUMN lu boolean; |
208 |
|
209 |
|
210 |
|
211 |
UPDATE evenement SET avis_decision=(select avis_decision.avis_decision from avis_decision where avis=avis_decision.avis_old); |
212 |
UPDATE instruction SET avis_decision=(select avis_decision.avis_decision from avis_decision where avis=avis_decision.avis_old); |
213 |
UPDATE dossier SET avis_decision=(select avis_decision.avis_decision from avis_decision where avis=avis_decision.avis_old); |
214 |
|
215 |
ALTER TABLE consultation DROP COLUMN avis; |
216 |
ALTER TABLE evenement DROP COLUMN avis; |
217 |
ALTER TABLE instruction DROP COLUMN avis; |
218 |
ALTER TABLE dossier DROP COLUMN avis; |
219 |
|
220 |
ALTER TABLE ONLY consultation |
221 |
ADD CONSTRAINT consultation_avis_consultation_fkey FOREIGN KEY (avis_consultation) REFERENCES avis_consultation(avis_consultation); |
222 |
ALTER TABLE ONLY evenement |
223 |
ADD CONSTRAINT evenement_avis_decision_fkey FOREIGN KEY (avis_decision) REFERENCES avis_decision(avis_decision); |
224 |
ALTER TABLE ONLY instruction |
225 |
ADD CONSTRAINT instruction_avis_decision_fkey FOREIGN KEY (avis_decision) REFERENCES avis_decision(avis_decision); |
226 |
ALTER TABLE ONLY dossier |
227 |
ADD CONSTRAINT dossier_avis_decision_fkey FOREIGN KEY (avis_decision) REFERENCES avis_decision(avis_decision); |
228 |
ALTER TABLE avis_decision DROP COLUMN avis_old; |
229 |
ALTER TABLE avis_consultation DROP COLUMN avis_old; |
230 |
DROP TABLE avis; |
231 |
DROP TABLE avis_consultation_tmp; |
232 |
|
233 |
-- |
234 |
-- Ajout des droits sur l'objet consultation_encours |
235 |
-- |
236 |
|
237 |
|
238 |
INSERT INTO om_widget VALUES (1, 1, 'Retours de consultations', '../scr/tab.php?obj=consultation_mes_retours', '<script type=''text/javascript''> |
239 |
$.ajax({ |
240 |
type: ''GET'', |
241 |
url:''../app/get_num_consult.php'', |
242 |
cache: false, |
243 |
success: function(html){ |
244 |
$(''#number_return'').append(html); |
245 |
} |
246 |
}); |
247 |
</script> |
248 |
<div id="number_return"></div>',2); |
249 |
|
250 |
-- |
251 |
-- Ajout des droits sur les nouvelles tables |
252 |
-- |
253 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'service_categorie', '4'); |
254 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_decision', '4'); |
255 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_consultation', '4'); |
256 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_service_categorie', '4'); |
257 |
|
258 |
ALTER TABLE consultation ALTER service SET NOT NULL; |
259 |
ALTER TABLE dossier ADD COLUMN enjeu_erp boolean; |
260 |
ALTER TABLE dossier ADD COLUMN enjeu_urba boolean; |
261 |
|
262 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_mes_retours', 4); |
263 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_tous_retours', 4); |
264 |
|
265 |
-- |
266 |
-- Modification de la structure des instructeurs |
267 |
-- |
268 |
CREATE SEQUENCE direction_seq |
269 |
START WITH 1 |
270 |
INCREMENT BY 1 |
271 |
NO MINVALUE |
272 |
NO MAXVALUE |
273 |
CACHE 1; |
274 |
|
275 |
CREATE TABLE direction ( |
276 |
direction integer NOT NULL, |
277 |
code character varying(20) NOT NULL, |
278 |
libelle character varying(100) NOT NULL, |
279 |
description text, |
280 |
chef character varying(100) NOT NULL, |
281 |
om_validite_debut date, |
282 |
om_validite_fin date, |
283 |
PRIMARY KEY (direction) |
284 |
); |
285 |
|
286 |
INSERT INTO direction VALUES (nextval('direction_seq'::regclass),'ADS', 'Direction ADS', 'Direction des autorisations des droits du sol', 'Mme Dupont', NULL, NULL); |
287 |
|
288 |
CREATE SEQUENCE division_seq |
289 |
START WITH 1 |
290 |
INCREMENT BY 1 |
291 |
NO MINVALUE |
292 |
NO MAXVALUE |
293 |
CACHE 1; |
294 |
|
295 |
CREATE TABLE division ( |
296 |
division integer NOT NULL, |
297 |
code character varying(20) NOT NULL, |
298 |
libelle character varying(100) NOT NULL, |
299 |
description text, |
300 |
chef character varying(100) NOT NULL, |
301 |
direction integer NOT NULL, |
302 |
om_validite_debut date, |
303 |
om_validite_fin date, |
304 |
PRIMARY KEY (division), |
305 |
FOREIGN KEY ( direction ) REFERENCES direction ( direction ) |
306 |
); |
307 |
|
308 |
INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1, NULL, NULL); |
309 |
|
310 |
CREATE SEQUENCE instructeur_seq |
311 |
START WITH 1 |
312 |
INCREMENT BY 1 |
313 |
NO MINVALUE |
314 |
NO MAXVALUE |
315 |
CACHE 1; |
316 |
|
317 |
CREATE TABLE instructeur ( |
318 |
instructeur integer NOT NULL, |
319 |
nom character varying(100) NOT NULL, |
320 |
telephone character varying(14), |
321 |
division integer NOT NULL, |
322 |
om_utilisateur integer, |
323 |
om_validite_debut date, |
324 |
om_validite_fin date, |
325 |
PRIMARY KEY ( instructeur ), |
326 |
FOREIGN KEY ( division ) REFERENCES division ( division ), |
327 |
FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur ) |
328 |
); |
329 |
|
330 |
-- Insertion des utilisateurs instructeurs dans la table instructeur |
331 |
INSERT INTO instructeur (instructeur,nom,telephone,division,om_utilisateur) |
332 |
(SELECT om_utilisateur,nom,telephone,1,om_utilisateur FROM om_utilisateur WHERE instructeur='Oui'); |
333 |
-- Mise a jour de la sequence |
334 |
SELECT setval('instructeur_seq',(SELECT MAX(instructeur) FROM instructeur)); |
335 |
|
336 |
-- Creation du parametre pour afficher ou non la division dans les dossiers |
337 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'afficher_division','false',1); |
338 |
|
339 |
-- Ajout des droits sur les tables d'organisation |
340 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'direction', '2'); |
341 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'division', '2'); |
342 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'instructeur', '2'); |
343 |
|
344 |
-- Modification de la clé étrangère dossier -> om_utilisateur par dossier -> instructeur |
345 |
ALTER TABLE dossier DROP CONSTRAINT dossier_instructeur_fkey; |
346 |
ALTER TABLE dossier ADD CONSTRAINT |
347 |
dossier_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
348 |
|
349 |
-- Ajout des parametres des liens dans la table om_parametre |
350 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'lien_interne_vdm', '',1); |
351 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'lien_externe', '',1); |
352 |
ALTER TABLE om_parametre ALTER COLUMN valeur TYPE character varying(150); |
353 |
|
354 |
|
355 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_code_barre', '2'); |
356 |
|
357 |
-- |
358 |
-- Ajout des tables arrondissement, quartier et lien_localisation_nature |
359 |
-- |
360 |
CREATE TABLE arrondissement ( |
361 |
arrondissement integer NOT NULL, |
362 |
libelle character varying(3) NOT NULL |
363 |
); |
364 |
|
365 |
ALTER TABLE ONLY arrondissement |
366 |
ADD CONSTRAINT arrondissement_pkey PRIMARY KEY (arrondissement); |
367 |
|
368 |
CREATE SEQUENCE arrondissement_seq |
369 |
INCREMENT 1 |
370 |
MINVALUE 1 |
371 |
MAXVALUE 9223372036854775807 |
372 |
START 1 |
373 |
CACHE 1; |
374 |
|
375 |
CREATE TABLE quartier ( |
376 |
quartier integer NOT NULL, |
377 |
arrondissement integer NOT NULL, |
378 |
code_impots character varying(3) NOT NULL, |
379 |
libelle character varying(40) NOT NULL |
380 |
); |
381 |
|
382 |
ALTER TABLE ONLY quartier |
383 |
ADD CONSTRAINT quartier_pkey PRIMARY KEY (quartier); |
384 |
ALTER TABLE ONLY quartier |
385 |
ADD CONSTRAINT quartier_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
386 |
|
387 |
CREATE SEQUENCE quartier_seq |
388 |
INCREMENT 1 |
389 |
MINVALUE 1 |
390 |
MAXVALUE 9223372036854775807 |
391 |
START 1 |
392 |
CACHE 1; |
393 |
|
394 |
CREATE TABLE lien_localisation_nature ( |
395 |
lien_localisation_nature integer NOT NULL, |
396 |
nature character varying(2), |
397 |
arrondissement integer, |
398 |
quartier integer , |
399 |
section varchar(2), |
400 |
instructeur integer NOT NULL |
401 |
); |
402 |
|
403 |
ALTER TABLE ONLY lien_localisation_nature |
404 |
ADD CONSTRAINT lien_localisation_nature_pkey PRIMARY KEY (lien_localisation_nature); |
405 |
ALTER TABLE ONLY lien_localisation_nature |
406 |
ADD CONSTRAINT lien_localisation_nature_nature_fkey FOREIGN KEY (nature) REFERENCES nature(nature); |
407 |
ALTER TABLE ONLY lien_localisation_nature |
408 |
ADD CONSTRAINT lien_localisation_nature_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
409 |
ALTER TABLE ONLY lien_localisation_nature |
410 |
ADD CONSTRAINT lien_localisation_nature_quartier_fkey FOREIGN KEY (quartier) REFERENCES quartier(quartier); |
411 |
ALTER TABLE ONLY lien_localisation_nature |
412 |
ADD CONSTRAINT lien_localisation_nature_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
413 |
|
414 |
CREATE SEQUENCE lien_localisation_nature_seq |
415 |
INCREMENT 1 |
416 |
MINVALUE 1 |
417 |
MAXVALUE 9223372036854775807 |
418 |
START 1 |
419 |
CACHE 1; |
420 |
|
421 |
-- Ajout des droits pour le retour des services |
422 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_encours', '2'); |
423 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_retour_service', '2'); |
424 |
|
425 |
-- Suppression des colonnes inutiles dans la table om_utilisateur |
426 |
ALTER TABLE om_utilisateur DROP instructeur; |
427 |
|
428 |
ALTER TABLE om_utilisateur DROP telephone; |
429 |
|
430 |
-- Ajout des droits sur lien_service_om_utilisateur |
431 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_om_utilisateur', '2'); |
432 |
-- Ajout des droits pour le retour des services |
433 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_passee', '2'); |
434 |
|
435 |
-- Ajout des droits sur lien_localisation_nature |
436 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_localisation_nature', '2'); |
437 |
|
438 |
-- Ajout du droit pour changer l'état (lu/non lu) d'une consultation |
439 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_modifier_lu', '2'); |
440 |
|
441 |
-- Changement de taille du champs parcelle de la table parcelle et terrain |
442 |
ALTER TABLE parcelle ALTER COLUMN parcelle TYPE character varying(20); |
443 |
ALTER TABLE terrain ALTER COLUMN parcelle TYPE character varying(20); |
444 |
|
445 |
|
446 |
-- |
447 |
-- Messages |
448 |
-- |
449 |
|
450 |
-- create sequence for the message ID generation |
451 |
CREATE SEQUENCE messages_seq |
452 |
START WITH 1 |
453 |
INCREMENT BY 1 |
454 |
NO MINVALUE |
455 |
NO MAXVALUE |
456 |
CACHE 1; |
457 |
|
458 |
-- Create table messages |
459 |
CREATE TABLE messages ( |
460 |
message integer PRIMARY KEY DEFAULT nextval('messages_seq'), |
461 |
dossier character varying(12), |
462 |
type character varying(60), |
463 |
emetteur character varying(40), |
464 |
date_emission DATE NOT NULL, |
465 |
lu boolean default FALSE, |
466 |
FOREIGN KEY ( dossier ) REFERENCES dossier ( dossier ) -- add this |
467 |
); |
468 |
ALTER SEQUENCE messages_seq OWNED BY messages.message; |
469 |
|
470 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'menu_suivi', '2'); |
471 |
|
472 |
-- Droit de l'ajout forcé d'un instructeur |
473 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'dossier_modifier_instructeur', '2'); |
474 |
|
475 |
-- Module 1 |
476 |
CREATE TABLE dossier_autorisation_type ( |
477 |
dossier_autorisation_type integer, |
478 |
code character varying(20), |
479 |
libelle character varying(100), |
480 |
description text, |
481 |
confidentiel boolean default FALSE |
482 |
); |
483 |
|
484 |
ALTER TABLE ONLY dossier_autorisation_type |
485 |
ADD CONSTRAINT dossier_autorisation_type_pkey PRIMARY KEY (dossier_autorisation_type); |
486 |
|
487 |
CREATE SEQUENCE dossier_autorisation_type_seq |
488 |
INCREMENT 1 |
489 |
MINVALUE 1 |
490 |
MAXVALUE 9223372036854775807 |
491 |
START 1 |
492 |
CACHE 1; |
493 |
|
494 |
-- |
495 |
|
496 |
CREATE TABLE dossier_autorisation_type_detaille ( |
497 |
dossier_autorisation_type_detaille integer, |
498 |
code character varying(20), |
499 |
libelle character varying(100), |
500 |
description text, |
501 |
dossier_autorisation_type integer |
502 |
); |
503 |
|
504 |
ALTER TABLE ONLY dossier_autorisation_type_detaille |
505 |
ADD CONSTRAINT dossier_autorisation_type_detaille_pkey PRIMARY KEY (dossier_autorisation_type_detaille); |
506 |
ALTER TABLE ONLY dossier_autorisation_type_detaille |
507 |
ADD CONSTRAINT dossier_autorisation_type_detaille_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type); |
508 |
|
509 |
CREATE SEQUENCE dossier_autorisation_type_detaille_seq |
510 |
INCREMENT 1 |
511 |
MINVALUE 1 |
512 |
MAXVALUE 9223372036854775807 |
513 |
START 1 |
514 |
CACHE 1; |
515 |
|
516 |
-- |
517 |
|
518 |
CREATE TABLE dossier_instruction_type ( |
519 |
dossier_instruction_type integer, |
520 |
code character varying(20), |
521 |
libelle character varying(100), |
522 |
description text, |
523 |
dossier_autorisation_type_detaille integer, |
524 |
suffixe boolean default FALSE |
525 |
); |
526 |
|
527 |
ALTER TABLE ONLY dossier_instruction_type |
528 |
ADD CONSTRAINT dossier_instruction_type_pkey PRIMARY KEY (dossier_instruction_type); |
529 |
ALTER TABLE ONLY dossier_instruction_type |
530 |
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); |
531 |
|
532 |
CREATE SEQUENCE dossier_instruction_type_seq |
533 |
INCREMENT 1 |
534 |
MINVALUE 1 |
535 |
MAXVALUE 9223372036854775807 |
536 |
START 1 |
537 |
CACHE 1; |
538 |
|
539 |
-- |
540 |
|
541 |
CREATE TABLE demande_genre ( |
542 |
demande_genre integer, |
543 |
code character varying(20), |
544 |
libelle character varying(100), |
545 |
description text |
546 |
); |
547 |
|
548 |
ALTER TABLE ONLY demande_genre |
549 |
ADD CONSTRAINT demande_genre_pkey PRIMARY KEY (demande_genre); |
550 |
|
551 |
CREATE SEQUENCE demande_genre_seq |
552 |
INCREMENT 1 |
553 |
MINVALUE 1 |
554 |
MAXVALUE 9223372036854775807 |
555 |
START 1 |
556 |
CACHE 1; |
557 |
|
558 |
-- |
559 |
|
560 |
CREATE TABLE groupe ( |
561 |
groupe integer, |
562 |
code character varying(20), |
563 |
libelle character varying(100), |
564 |
description text, |
565 |
demande_genre integer |
566 |
); |
567 |
|
568 |
ALTER TABLE ONLY groupe |
569 |
ADD CONSTRAINT groupe_pkey PRIMARY KEY (groupe); |
570 |
ALTER TABLE ONLY groupe |
571 |
ADD CONSTRAINT groupe_demande_genre_fkey FOREIGN KEY (demande_genre) REFERENCES demande_genre(demande_genre); |
572 |
|
573 |
CREATE SEQUENCE groupe_seq |
574 |
INCREMENT 1 |
575 |
MINVALUE 1 |
576 |
MAXVALUE 9223372036854775807 |
577 |
START 1 |
578 |
CACHE 1; |
579 |
|
580 |
-- Ajout de clé étrangère à la table dossier_autorisation_type |
581 |
ALTER TABLE dossier_autorisation_type ADD COLUMN groupe integer; |
582 |
ALTER TABLE ONLY dossier_autorisation_type |
583 |
ADD CONSTRAINT dossier_autorisation_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe); |
584 |
|
585 |
--Demande nature |
586 |
|
587 |
CREATE TABLE demande_nature ( |
588 |
demande_nature integer, |
589 |
code character varying(20), |
590 |
libelle character varying(100), |
591 |
description text |
592 |
); |
593 |
|
594 |
ALTER TABLE ONLY demande_nature |
595 |
ADD CONSTRAINT demande_nature_pkey PRIMARY KEY (demande_nature); |
596 |
|
597 |
CREATE SEQUENCE demande_nature_seq |
598 |
INCREMENT 1 |
599 |
MINVALUE 1 |
600 |
MAXVALUE 9223372036854775807 |
601 |
START 1 |
602 |
CACHE 1; |
603 |
|
604 |
--Demande type |
605 |
|
606 |
CREATE TABLE demande_type ( |
607 |
demande_type integer, |
608 |
code character varying(20), |
609 |
libelle character varying(100), |
610 |
description text, |
611 |
demande_nature integer, |
612 |
groupe integer, |
613 |
dossier_instruction_type integer, |
614 |
dossier_autorisation_type_detaille integer, |
615 |
contraintes character varying(20), |
616 |
etats_dossier_autorisation_autorises character varying(100), |
617 |
qualification boolean, |
618 |
evenement integer |
619 |
); |
620 |
|
621 |
ALTER TABLE ONLY demande_type |
622 |
ADD CONSTRAINT demande_type_pkey PRIMARY KEY (demande_type); |
623 |
ALTER TABLE ONLY demande_type |
624 |
ADD CONSTRAINT demande_type_demande_nature_fkey FOREIGN KEY (demande_nature) REFERENCES demande_nature(demande_nature); |
625 |
ALTER TABLE ONLY demande_type |
626 |
ADD CONSTRAINT demande_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe); |
627 |
ALTER TABLE ONLY demande_type |
628 |
ADD CONSTRAINT demande_type_dossier_instruction_type_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type); |
629 |
ALTER TABLE ONLY demande_type |
630 |
ADD CONSTRAINT demande_type_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille); |
631 |
ALTER TABLE ONLY demande_type |
632 |
ADD CONSTRAINT demande_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement); |
633 |
|
634 |
CREATE SEQUENCE demande_type_seq |
635 |
INCREMENT 1 |
636 |
MINVALUE 1 |
637 |
MAXVALUE 9223372036854775807 |
638 |
START 1 |
639 |
CACHE 1; |
640 |
|
641 |
-- |
642 |
|
643 |
CREATE TABLE lien_evenement_dossier_autorisation_type ( |
644 |
lien_evenement_dossier_autorisation_type integer, |
645 |
evenement integer, |
646 |
dossier_autorisation_type integer |
647 |
); |
648 |
|
649 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
650 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_pkey PRIMARY KEY (lien_evenement_dossier_autorisation_type); |
651 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
652 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement); |
653 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
654 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type); |
655 |
|
656 |
CREATE SEQUENCE lien_evenement_dossier_autorisation_type_seq |
657 |
INCREMENT 1 |
658 |
MINVALUE 1 |
659 |
MAXVALUE 9223372036854775807 |
660 |
START 1 |
661 |
CACHE 1; |
662 |
|
663 |
-- |
664 |
|
665 |
CREATE TABLE autorite_competente ( |
666 |
autorite_competente integer, |
667 |
code character varying(20), |
668 |
libelle character varying(100), |
669 |
description text |
670 |
); |
671 |
|
672 |
ALTER TABLE ONLY autorite_competente |
673 |
ADD CONSTRAINT autorite_competente_pkey PRIMARY KEY (autorite_competente); |
674 |
|
675 |
CREATE SEQUENCE autorite_competente_seq |
676 |
INCREMENT 1 |
677 |
MINVALUE 1 |
678 |
MAXVALUE 9223372036854775807 |
679 |
START 1 |
680 |
CACHE 1; |
681 |
|
682 |
-- Ajout de clé étrangère à la table dossier_autorisation_type |
683 |
ALTER TABLE dossier ADD COLUMN autorite_competente integer; |
684 |
ALTER TABLE ONLY dossier |
685 |
ADD CONSTRAINT dossier_autorite_competente_fkey FOREIGN KEY (autorite_competente) REFERENCES autorite_competente(autorite_competente); |
686 |
|
687 |
-- Donnees des tables |
688 |
INSERT INTO dossier_autorisation_type(dossier_autorisation_type, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature; |
689 |
INSERT INTO dossier_autorisation_type_detaille(dossier_autorisation_type_detaille, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature; |
690 |
|
691 |
INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'URBA', 'Pôle Urbanisme', 'Responsabilité de la DDU'); |
692 |
INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'ERP', 'Pôle ERP', 'Responsabilité de la DGUP'); |
693 |
|
694 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ADS', 'Autorisation ADS', '',1); |
695 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CTX', 'Contentieux dans le domaine urbanisme', '',1); |
696 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CU', 'Changement d''usage', '',1); |
697 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'RU', 'Renseignement d''urbanisme', '',1); |
698 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ERP', 'ERP', '',2); |