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 les nouvelles tables |
235 |
-- |
236 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'service_categorie', '4'); |
237 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_decision', '4'); |
238 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_consultation', '4'); |
239 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_service_categorie', '4'); |
240 |
|
241 |
ALTER TABLE consultation ALTER service SET NOT NULL; |
242 |
ALTER TABLE dossier ADD COLUMN enjeu_erp boolean; |
243 |
ALTER TABLE dossier ADD COLUMN enjeu_urba boolean; |
244 |
|
245 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_mes_retours', 4); |
246 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_tous_retours', 4); |
247 |
|
248 |
-- |
249 |
-- Modification de la structure des instructeurs |
250 |
-- |
251 |
CREATE SEQUENCE direction_seq |
252 |
START WITH 1 |
253 |
INCREMENT BY 1 |
254 |
NO MINVALUE |
255 |
NO MAXVALUE |
256 |
CACHE 1; |
257 |
|
258 |
CREATE TABLE direction ( |
259 |
direction integer NOT NULL, |
260 |
code character varying(20) NOT NULL, |
261 |
libelle character varying(100) NOT NULL, |
262 |
description text, |
263 |
chef character varying(100) NOT NULL, |
264 |
om_validite_debut date, |
265 |
om_validite_fin date, |
266 |
PRIMARY KEY (direction) |
267 |
); |
268 |
|
269 |
INSERT INTO direction VALUES (nextval('direction_seq'::regclass),'ADS', 'Direction ADS', 'Direction des autorisations des droits du sol', 'Mme Dupont', NULL, NULL); |
270 |
|
271 |
CREATE SEQUENCE division_seq |
272 |
START WITH 1 |
273 |
INCREMENT BY 1 |
274 |
NO MINVALUE |
275 |
NO MAXVALUE |
276 |
CACHE 1; |
277 |
|
278 |
CREATE TABLE division ( |
279 |
division integer NOT NULL, |
280 |
code character varying(20) NOT NULL, |
281 |
libelle character varying(100) NOT NULL, |
282 |
description text, |
283 |
chef character varying(100) NOT NULL, |
284 |
direction integer NOT NULL, |
285 |
om_validite_debut date, |
286 |
om_validite_fin date, |
287 |
PRIMARY KEY (division), |
288 |
FOREIGN KEY ( direction ) REFERENCES direction ( direction ) |
289 |
); |
290 |
|
291 |
INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1, NULL, NULL); |
292 |
|
293 |
CREATE SEQUENCE instructeur_seq |
294 |
START WITH 1 |
295 |
INCREMENT BY 1 |
296 |
NO MINVALUE |
297 |
NO MAXVALUE |
298 |
CACHE 1; |
299 |
|
300 |
CREATE TABLE instructeur ( |
301 |
instructeur integer NOT NULL, |
302 |
nom character varying(100) NOT NULL, |
303 |
telephone character varying(14), |
304 |
division integer NOT NULL, |
305 |
om_utilisateur integer, |
306 |
om_validite_debut date, |
307 |
om_validite_fin date, |
308 |
PRIMARY KEY ( instructeur ), |
309 |
FOREIGN KEY ( division ) REFERENCES division ( division ), |
310 |
FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur ) |
311 |
); |
312 |
|
313 |
-- Insertion des utilisateurs instructeurs dans la table instructeur |
314 |
INSERT INTO instructeur (instructeur,nom,telephone,division,om_utilisateur) |
315 |
(SELECT om_utilisateur,nom,telephone,1,om_utilisateur FROM om_utilisateur WHERE instructeur='Oui'); |
316 |
-- Mise a jour de la sequence |
317 |
SELECT setval('instructeur_seq',(SELECT MAX(instructeur) FROM instructeur)); |
318 |
|
319 |
-- Creation du parametre pour afficher ou non la division dans les dossiers |
320 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'afficher_division','false',1); |
321 |
|
322 |
-- Ajout des droits sur les tables d'organisation |
323 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'direction', '2'); |
324 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'division', '2'); |
325 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'instructeur', '2'); |
326 |
|
327 |
-- Modification de la clé étrangère dossier -> om_utilisateur par dossier -> instructeur |
328 |
ALTER TABLE dossier DROP CONSTRAINT dossier_instructeur_fkey; |
329 |
ALTER TABLE dossier ADD CONSTRAINT |
330 |
dossier_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
331 |
|
332 |
-- Ajout des parametres des liens dans la table om_parametre |
333 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'services_consultes_lien_interne', '',1); |
334 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'services_consultes_lien_externe', '',1); |
335 |
ALTER TABLE om_parametre ALTER COLUMN valeur TYPE character varying(150); |
336 |
|
337 |
|
338 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_code_barre', '2'); |
339 |
|
340 |
-- |
341 |
-- Ajout des tables arrondissement, quartier et lien_localisation_nature |
342 |
-- |
343 |
CREATE TABLE arrondissement ( |
344 |
arrondissement integer NOT NULL, |
345 |
libelle character varying(3) NOT NULL |
346 |
); |
347 |
|
348 |
ALTER TABLE ONLY arrondissement |
349 |
ADD CONSTRAINT arrondissement_pkey PRIMARY KEY (arrondissement); |
350 |
|
351 |
CREATE SEQUENCE arrondissement_seq |
352 |
INCREMENT 1 |
353 |
MINVALUE 1 |
354 |
MAXVALUE 9223372036854775807 |
355 |
START 1 |
356 |
CACHE 1; |
357 |
|
358 |
CREATE TABLE quartier ( |
359 |
quartier integer NOT NULL, |
360 |
arrondissement integer NOT NULL, |
361 |
code_impots character varying(3) NOT NULL, |
362 |
libelle character varying(40) NOT NULL |
363 |
); |
364 |
|
365 |
ALTER TABLE ONLY quartier |
366 |
ADD CONSTRAINT quartier_pkey PRIMARY KEY (quartier); |
367 |
ALTER TABLE ONLY quartier |
368 |
ADD CONSTRAINT quartier_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
369 |
|
370 |
CREATE SEQUENCE quartier_seq |
371 |
INCREMENT 1 |
372 |
MINVALUE 1 |
373 |
MAXVALUE 9223372036854775807 |
374 |
START 1 |
375 |
CACHE 1; |
376 |
|
377 |
CREATE TABLE lien_localisation_nature ( |
378 |
lien_localisation_nature integer NOT NULL, |
379 |
nature character varying(2), |
380 |
arrondissement integer, |
381 |
quartier integer , |
382 |
section varchar(2), |
383 |
instructeur integer NOT NULL |
384 |
); |
385 |
|
386 |
ALTER TABLE ONLY lien_localisation_nature |
387 |
ADD CONSTRAINT lien_localisation_nature_pkey PRIMARY KEY (lien_localisation_nature); |
388 |
ALTER TABLE ONLY lien_localisation_nature |
389 |
ADD CONSTRAINT lien_localisation_nature_nature_fkey FOREIGN KEY (nature) REFERENCES nature(nature); |
390 |
ALTER TABLE ONLY lien_localisation_nature |
391 |
ADD CONSTRAINT lien_localisation_nature_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
392 |
ALTER TABLE ONLY lien_localisation_nature |
393 |
ADD CONSTRAINT lien_localisation_nature_quartier_fkey FOREIGN KEY (quartier) REFERENCES quartier(quartier); |
394 |
ALTER TABLE ONLY lien_localisation_nature |
395 |
ADD CONSTRAINT lien_localisation_nature_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
396 |
|
397 |
CREATE SEQUENCE lien_localisation_nature_seq |
398 |
INCREMENT 1 |
399 |
MINVALUE 1 |
400 |
MAXVALUE 9223372036854775807 |
401 |
START 1 |
402 |
CACHE 1; |
403 |
|
404 |
-- Ajout des droits pour le retour des services |
405 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_encours', '2'); |
406 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_retour_service', '2'); |
407 |
|
408 |
-- Suppression des colonnes inutiles dans la table om_utilisateur |
409 |
ALTER TABLE om_utilisateur DROP instructeur; |
410 |
|
411 |
ALTER TABLE om_utilisateur DROP telephone; |
412 |
|
413 |
-- Ajout des droits sur lien_service_om_utilisateur |
414 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_om_utilisateur', '2'); |
415 |
-- Ajout des droits pour le retour des services |
416 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_passee', '2'); |
417 |
|
418 |
-- Ajout des droits sur lien_localisation_nature |
419 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_localisation_nature', '2'); |
420 |
|
421 |
-- Ajout du droit pour changer l'état (lu/non lu) d'une consultation |
422 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_modifier_lu', '2'); |
423 |
|
424 |
-- Changement de taille du champs parcelle de la table parcelle et terrain |
425 |
ALTER TABLE parcelle ALTER COLUMN parcelle TYPE character varying(20); |
426 |
ALTER TABLE terrain ALTER COLUMN parcelle TYPE character varying(20); |
427 |
|
428 |
|
429 |
-- |
430 |
-- Messages |
431 |
-- |
432 |
|
433 |
-- create sequence for the message ID generation |
434 |
CREATE SEQUENCE messages_seq |
435 |
START WITH 1 |
436 |
INCREMENT BY 1 |
437 |
NO MINVALUE |
438 |
NO MAXVALUE |
439 |
CACHE 1; |
440 |
|
441 |
-- Create table messages |
442 |
CREATE TABLE messages ( |
443 |
message integer PRIMARY KEY DEFAULT nextval('messages_seq'), |
444 |
dossier character varying(12), |
445 |
type character varying(60), |
446 |
emetteur character varying(40), |
447 |
date_emission DATE NOT NULL, |
448 |
lu boolean default FALSE, |
449 |
FOREIGN KEY ( dossier ) REFERENCES dossier ( dossier ) -- add this |
450 |
); |
451 |
ALTER SEQUENCE messages_seq OWNED BY messages.message; |
452 |
|
453 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'menu_suivi', '2'); |
454 |
|
455 |
-- Droit de l'ajout forcé d'un instructeur |
456 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'dossier_modifier_instructeur', '2'); |
457 |
|
458 |
-- Module 1 |
459 |
CREATE TABLE dossier_autorisation_type ( |
460 |
dossier_autorisation_type integer, |
461 |
code character varying(20), |
462 |
libelle character varying(100), |
463 |
description text, |
464 |
confidentiel boolean default FALSE |
465 |
); |
466 |
|
467 |
ALTER TABLE ONLY dossier_autorisation_type |
468 |
ADD CONSTRAINT dossier_autorisation_type_pkey PRIMARY KEY (dossier_autorisation_type); |
469 |
|
470 |
CREATE SEQUENCE dossier_autorisation_type_seq |
471 |
INCREMENT 1 |
472 |
MINVALUE 1 |
473 |
MAXVALUE 9223372036854775807 |
474 |
START 1 |
475 |
CACHE 1; |
476 |
|
477 |
-- |
478 |
|
479 |
CREATE TABLE dossier_autorisation_type_detaille ( |
480 |
dossier_autorisation_type_detaille integer, |
481 |
code character varying(20), |
482 |
libelle character varying(100), |
483 |
description text, |
484 |
dossier_autorisation_type integer |
485 |
); |
486 |
|
487 |
ALTER TABLE ONLY dossier_autorisation_type_detaille |
488 |
ADD CONSTRAINT dossier_autorisation_type_detaille_pkey PRIMARY KEY (dossier_autorisation_type_detaille); |
489 |
ALTER TABLE ONLY dossier_autorisation_type_detaille |
490 |
ADD CONSTRAINT dossier_autorisation_type_detaille_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type); |
491 |
|
492 |
CREATE SEQUENCE dossier_autorisation_type_detaille_seq |
493 |
INCREMENT 1 |
494 |
MINVALUE 1 |
495 |
MAXVALUE 9223372036854775807 |
496 |
START 1 |
497 |
CACHE 1; |
498 |
|
499 |
-- |
500 |
|
501 |
CREATE TABLE dossier_instruction_type ( |
502 |
dossier_instruction_type integer, |
503 |
code character varying(20), |
504 |
libelle character varying(100), |
505 |
description text, |
506 |
dossier_autorisation_type_detaille integer, |
507 |
suffixe boolean default FALSE |
508 |
); |
509 |
|
510 |
ALTER TABLE ONLY dossier_instruction_type |
511 |
ADD CONSTRAINT dossier_instruction_type_pkey PRIMARY KEY (dossier_instruction_type); |
512 |
ALTER TABLE ONLY dossier_instruction_type |
513 |
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); |
514 |
|
515 |
CREATE SEQUENCE dossier_instruction_type_seq |
516 |
INCREMENT 1 |
517 |
MINVALUE 1 |
518 |
MAXVALUE 9223372036854775807 |
519 |
START 1 |
520 |
CACHE 1; |
521 |
|
522 |
-- |
523 |
|
524 |
CREATE TABLE demande_genre ( |
525 |
demande_genre integer, |
526 |
code character varying(20), |
527 |
libelle character varying(100), |
528 |
description text |
529 |
); |
530 |
|
531 |
ALTER TABLE ONLY demande_genre |
532 |
ADD CONSTRAINT demande_genre_pkey PRIMARY KEY (demande_genre); |
533 |
|
534 |
CREATE SEQUENCE demande_genre_seq |
535 |
INCREMENT 1 |
536 |
MINVALUE 1 |
537 |
MAXVALUE 9223372036854775807 |
538 |
START 1 |
539 |
CACHE 1; |
540 |
|
541 |
-- |
542 |
|
543 |
CREATE TABLE groupe ( |
544 |
groupe integer, |
545 |
code character varying(20), |
546 |
libelle character varying(100), |
547 |
description text, |
548 |
demande_genre integer |
549 |
); |
550 |
|
551 |
ALTER TABLE ONLY groupe |
552 |
ADD CONSTRAINT groupe_pkey PRIMARY KEY (groupe); |
553 |
ALTER TABLE ONLY groupe |
554 |
ADD CONSTRAINT groupe_demande_genre_fkey FOREIGN KEY (demande_genre) REFERENCES demande_genre(demande_genre); |
555 |
|
556 |
CREATE SEQUENCE groupe_seq |
557 |
INCREMENT 1 |
558 |
MINVALUE 1 |
559 |
MAXVALUE 9223372036854775807 |
560 |
START 1 |
561 |
CACHE 1; |
562 |
|
563 |
-- Ajout de clé étrangère à la table dossier_autorisation_type |
564 |
ALTER TABLE dossier_autorisation_type ADD COLUMN groupe integer; |
565 |
ALTER TABLE ONLY dossier_autorisation_type |
566 |
ADD CONSTRAINT dossier_autorisation_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe); |
567 |
|
568 |
--Demande nature |
569 |
|
570 |
CREATE TABLE demande_nature ( |
571 |
demande_nature integer, |
572 |
code character varying(20), |
573 |
libelle character varying(100), |
574 |
description text |
575 |
); |
576 |
|
577 |
ALTER TABLE ONLY demande_nature |
578 |
ADD CONSTRAINT demande_nature_pkey PRIMARY KEY (demande_nature); |
579 |
|
580 |
CREATE SEQUENCE demande_nature_seq |
581 |
INCREMENT 1 |
582 |
MINVALUE 1 |
583 |
MAXVALUE 9223372036854775807 |
584 |
START 1 |
585 |
CACHE 1; |
586 |
|
587 |
--Demande type |
588 |
|
589 |
CREATE TABLE demande_type ( |
590 |
demande_type integer, |
591 |
code character varying(20), |
592 |
libelle character varying(100), |
593 |
description text, |
594 |
demande_nature integer, |
595 |
groupe integer, |
596 |
dossier_instruction_type integer, |
597 |
dossier_autorisation_type_detaille integer, |
598 |
contraintes character varying(20), |
599 |
etats_dossier_autorisation_autorises character varying(100), |
600 |
qualification boolean, |
601 |
evenement integer |
602 |
); |
603 |
|
604 |
ALTER TABLE ONLY demande_type |
605 |
ADD CONSTRAINT demande_type_pkey PRIMARY KEY (demande_type); |
606 |
ALTER TABLE ONLY demande_type |
607 |
ADD CONSTRAINT demande_type_demande_nature_fkey FOREIGN KEY (demande_nature) REFERENCES demande_nature(demande_nature); |
608 |
ALTER TABLE ONLY demande_type |
609 |
ADD CONSTRAINT demande_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe); |
610 |
ALTER TABLE ONLY demande_type |
611 |
ADD CONSTRAINT demande_type_dossier_instruction_type_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type); |
612 |
ALTER TABLE ONLY demande_type |
613 |
ADD CONSTRAINT demande_type_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille); |
614 |
ALTER TABLE ONLY demande_type |
615 |
ADD CONSTRAINT demande_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement); |
616 |
|
617 |
CREATE SEQUENCE demande_type_seq |
618 |
INCREMENT 1 |
619 |
MINVALUE 1 |
620 |
MAXVALUE 9223372036854775807 |
621 |
START 1 |
622 |
CACHE 1; |
623 |
|
624 |
-- |
625 |
|
626 |
CREATE TABLE lien_evenement_dossier_autorisation_type ( |
627 |
lien_evenement_dossier_autorisation_type integer, |
628 |
evenement integer, |
629 |
dossier_autorisation_type integer |
630 |
); |
631 |
|
632 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
633 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_pkey PRIMARY KEY (lien_evenement_dossier_autorisation_type); |
634 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
635 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement); |
636 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
637 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type); |
638 |
|
639 |
CREATE SEQUENCE lien_evenement_dossier_autorisation_type_seq |
640 |
INCREMENT 1 |
641 |
MINVALUE 1 |
642 |
MAXVALUE 9223372036854775807 |
643 |
START 1 |
644 |
CACHE 1; |
645 |
|
646 |
-- |
647 |
|
648 |
CREATE TABLE autorite_competente ( |
649 |
autorite_competente integer, |
650 |
code character varying(20), |
651 |
libelle character varying(100), |
652 |
description text |
653 |
); |
654 |
|
655 |
ALTER TABLE ONLY autorite_competente |
656 |
ADD CONSTRAINT autorite_competente_pkey PRIMARY KEY (autorite_competente); |
657 |
|
658 |
CREATE SEQUENCE autorite_competente_seq |
659 |
INCREMENT 1 |
660 |
MINVALUE 1 |
661 |
MAXVALUE 9223372036854775807 |
662 |
START 1 |
663 |
CACHE 1; |
664 |
|
665 |
-- Ajout de clé étrangère à la table dossier_autorisation_type |
666 |
ALTER TABLE dossier ADD COLUMN autorite_competente integer; |
667 |
ALTER TABLE ONLY dossier |
668 |
ADD CONSTRAINT dossier_autorite_competente_fkey FOREIGN KEY (autorite_competente) REFERENCES autorite_competente(autorite_competente); |
669 |
|
670 |
-- Donnees des tables |
671 |
INSERT INTO dossier_autorisation_type(dossier_autorisation_type, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature; |
672 |
INSERT INTO dossier_autorisation_type_detaille(dossier_autorisation_type_detaille, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature; |
673 |
|
674 |
INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'URBA', 'Pôle Urbanisme', 'Responsabilité de la DDU'); |
675 |
INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'ERP', 'Pôle ERP', 'Responsabilité de la DGUP'); |
676 |
|
677 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ADS', 'Autorisation ADS', '',1); |
678 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CTX', 'Contentieux dans le domaine urbanisme', '',1); |
679 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CU', 'Changement d''usage', '',1); |
680 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'RU', 'Renseignement d''urbanisme', '',1); |
681 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ERP', 'ERP', '',2); |
682 |
|
683 |
-- Table Demande |
684 |
|
685 |
CREATE TABLE demande ( |
686 |
demande integer, |
687 |
dossier_autorisation_type_detaille integer, |
688 |
demande_type integer, |
689 |
date_demande date, |
690 |
terrain_references_cadastrales character varying(100), |
691 |
terrain_adresse_voie_numero integer, |
692 |
complement character varying(30), |
693 |
terrain_adresse_lieu_dit character varying(30), |
694 |
terrain_adresse_localite character varying(30), |
695 |
terrain_adresse_code_postal character varying(5), |
696 |
terrain_adresse_bp character varying(15), |
697 |
terrain_adresse_cedex character varying(15), |
698 |
terrain_superficie double precision, |
699 |
nombre_lots integer |
700 |
); |
701 |
|
702 |
ALTER TABLE ONLY demande |
703 |
ADD CONSTRAINT demande_pkey PRIMARY KEY (demande); |
704 |
ALTER TABLE ONLY demande |
705 |
ADD CONSTRAINT demande_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille); |
706 |
ALTER TABLE ONLY demande |
707 |
ADD CONSTRAINT demande_type_demande_type_fkey FOREIGN KEY (demande_type) REFERENCES demande_type(demande_type); |
708 |
|
709 |
CREATE SEQUENCE demande_seq |
710 |
INCREMENT 1 |
711 |
MINVALUE 1 |
712 |
MAXVALUE 9223372036854775807 |
713 |
START 1 |
714 |
CACHE 1; |
715 |
|
716 |
-- Table Demandeur |
717 |
|
718 |
CREATE TABLE demandeur ( |
719 |
demandeur integer, |
720 |
type_demandeur character varying(40), |
721 |
particulier_civilite character varying(10), |
722 |
particulier_nom character varying(40), |
723 |
particulier_prenom character varying(40), |
724 |
particulier_date_naissance date, |
725 |
particulier_commune_naissance character varying(30), |
726 |
particulier_departement_naissance character varying(80), |
727 |
personne_morale_denomination character varying(15), |
728 |
personne_morale_raison_sociale character varying(15), |
729 |
personne_morale_siret character varying(15), |
730 |
personne_morale_categorie_juridique character varying(15), |
731 |
personne_morale_civilite character varying(10), |
732 |
personne_morale_nom character varying(40), |
733 |
personne_morale_prenom character varying(40), |
734 |
numero character varying(5), |
735 |
voie character varying(40), |
736 |
complement character varying(39), |
737 |
lieu_dit character varying(39), |
738 |
localite character varying(30), |
739 |
code_postal character varying(5), |
740 |
bp character varying(5), |
741 |
cedex character varying(5), |
742 |
pays character varying(40), |
743 |
division_territoriale character varying(40), |
744 |
telephone_fixe character varying(14), |
745 |
telephone_mobile character varying(14), |
746 |
indicatif character varying(5), |
747 |
courriel character varying(40), |
748 |
notification boolean, |
749 |
frequent boolean, |
750 |
demande integer |
751 |
); |
752 |
|
753 |
ALTER TABLE ONLY demandeur |
754 |
ADD CONSTRAINT demandeur_pkey PRIMARY KEY (demandeur); |
755 |
ALTER TABLE ONLY demandeur |
756 |
ADD CONSTRAINT demandeur_particulier_civilite_fkey FOREIGN KEY (particulier_civilite) REFERENCES civilite(civilite); |
757 |
ALTER TABLE ONLY demandeur |
758 |
ADD CONSTRAINT demandeur_personne_morale_civilite_fkey FOREIGN KEY (personne_morale_civilite) REFERENCES civilite(civilite); |
759 |
ALTER TABLE ONLY demandeur |
760 |
ADD CONSTRAINT demandeur_demande_fkey FOREIGN KEY (demande) REFERENCES demande(demande); |
761 |
|
762 |
CREATE SEQUENCE demandeur_seq |
763 |
INCREMENT 1 |
764 |
MINVALUE 1 |
765 |
MAXVALUE 9223372036854775807 |
766 |
START 1 |
767 |
CACHE 1; |
768 |
|
769 |
-- Table lot |
770 |
|
771 |
CREATE TABLE lot ( |
772 |
lot integer, |
773 |
dossier character varying(12) |
774 |
); |
775 |
|
776 |
ALTER TABLE ONLY lot |
777 |
ADD CONSTRAINT lot_pkey PRIMARY KEY (lot); |
778 |
ALTER TABLE ONLY lot |
779 |
ADD CONSTRAINT lot_dossier_fkey FOREIGN KEY (dossier) REFERENCES dossier(dossier); |
780 |
|
781 |
CREATE SEQUENCE lot_seq |
782 |
INCREMENT 1 |
783 |
MINVALUE 1 |
784 |
MAXVALUE 9223372036854775807 |
785 |
START 1 |
786 |
CACHE 1; |
787 |
|
788 |
-- Table lien_lot_demandeur |
789 |
|
790 |
CREATE TABLE lien_lot_demandeur ( |
791 |
lien_lot_demandeur integer, |
792 |
lot integer, |
793 |
demandeur integer |
794 |
); |
795 |
|
796 |
ALTER TABLE ONLY lien_lot_demandeur |
797 |
ADD CONSTRAINT lien_lot_demandeur_pkey PRIMARY KEY (lien_lot_demandeur); |
798 |
ALTER TABLE ONLY lien_lot_demandeur |
799 |
ADD CONSTRAINT lien_lot_demandeur_lot_fkey FOREIGN KEY (lot) REFERENCES lot(lot); |
800 |
ALTER TABLE ONLY lien_lot_demandeur |
801 |
ADD CONSTRAINT lien_lot_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur); |
802 |
|
803 |
CREATE SEQUENCE lien_lot_demandeur_seq |
804 |
INCREMENT 1 |
805 |
MINVALUE 1 |
806 |
MAXVALUE 9223372036854775807 |
807 |
START 1 |
808 |
CACHE 1; |
809 |
|
810 |
|
811 |
--- |
812 |
--- Nouvelle gestion des tableaux de bord |
813 |
--- |
814 |
|
815 |
CREATE TABLE om_dashboard ( |
816 |
om_dashboard integer NOT NULL, |
817 |
om_profil integer NOT NULL, |
818 |
bloc character varying(10) NOT NULL, |
819 |
position integer, |
820 |
om_widget integer NOT NULL |
821 |
); |
822 |
|
823 |
ALTER TABLE ONLY om_dashboard |
824 |
ADD CONSTRAINT om_dashboard_pkey PRIMARY KEY (om_dashboard); |
825 |
ALTER TABLE ONLY om_dashboard |
826 |
ADD CONSTRAINT om_dashboard_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil); |
827 |
ALTER TABLE ONLY om_dashboard |
828 |
ADD CONSTRAINT om_dashboard_om_widget_fkey FOREIGN KEY (om_widget) REFERENCES om_widget(om_widget); |
829 |
|
830 |
CREATE SEQUENCE om_dashboard_seq |
831 |
START WITH 1 |
832 |
INCREMENT BY 1 |
833 |
NO MINVALUE |
834 |
NO MAXVALUE |
835 |
CACHE 1; |
836 |
|
837 |
SELECT pg_catalog.setval('om_dashboard_seq', 1, false); |
838 |
|
839 |
ALTER TABLE om_widget |
840 |
DROP CONSTRAINT om_widget_om_profil_fkey; |
841 |
|
842 |
ALTER TABlE om_widget DROP COLUMN om_profil; |
843 |
|
844 |
ALTER TABLE om_widget ADD COLUMN "type" character varying(40) NOT NULL DEFAULT 'web'::character varying; |
845 |
ALTER TABLE om_widget ALTER COLUMN "lien" SET DEFAULT ''::character varying; |
846 |
ALTER TABLE om_widget ALTER COLUMN "texte" SET DEFAULT ''::text; |
847 |
|
848 |
|