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 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'PC', 2); -- droit d'instructeur |
248 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_mes_retours', 2); -- droit d'instructeur |
249 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_tous_retours', 2); -- droit d'instructeur |
250 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_consulter', 2); -- droit d'instructeur |
251 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_modifier', 2); -- droit d'instructeur |
252 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages_tab', 2); -- droit d'instructeur |
253 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dossier', 2); -- droit d'instructeur |
254 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'dashboard', 2); -- droit d'instructeur |
255 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'menu_instruction', 2); -- droit d'instructeur |
256 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'), 'messages', 2); -- droit d'instructeur |
257 |
|
258 |
|
259 |
-- |
260 |
-- Modification de la structure des instructeurs |
261 |
-- |
262 |
CREATE SEQUENCE direction_seq |
263 |
START WITH 1 |
264 |
INCREMENT BY 1 |
265 |
NO MINVALUE |
266 |
NO MAXVALUE |
267 |
CACHE 1; |
268 |
|
269 |
CREATE TABLE direction ( |
270 |
direction integer NOT NULL, |
271 |
code character varying(20) NOT NULL, |
272 |
libelle character varying(100) NOT NULL, |
273 |
description text, |
274 |
chef character varying(100) NOT NULL, |
275 |
om_validite_debut date, |
276 |
om_validite_fin date, |
277 |
PRIMARY KEY (direction) |
278 |
); |
279 |
|
280 |
INSERT INTO direction VALUES (nextval('direction_seq'::regclass),'ADS', 'Direction ADS', 'Direction des autorisations des droits du sol', 'Mme Dupont', NULL, NULL); |
281 |
|
282 |
CREATE SEQUENCE division_seq |
283 |
START WITH 1 |
284 |
INCREMENT BY 1 |
285 |
NO MINVALUE |
286 |
NO MAXVALUE |
287 |
CACHE 1; |
288 |
|
289 |
CREATE TABLE division ( |
290 |
division integer NOT NULL, |
291 |
code character varying(20) NOT NULL, |
292 |
libelle character varying(100) NOT NULL, |
293 |
description text, |
294 |
chef character varying(100) NOT NULL, |
295 |
direction integer NOT NULL, |
296 |
om_validite_debut date, |
297 |
om_validite_fin date, |
298 |
PRIMARY KEY (division), |
299 |
FOREIGN KEY ( direction ) REFERENCES direction ( direction ) |
300 |
); |
301 |
|
302 |
INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1, NULL, NULL); |
303 |
|
304 |
CREATE SEQUENCE instructeur_seq |
305 |
START WITH 1 |
306 |
INCREMENT BY 1 |
307 |
NO MINVALUE |
308 |
NO MAXVALUE |
309 |
CACHE 1; |
310 |
|
311 |
CREATE TABLE instructeur ( |
312 |
instructeur integer NOT NULL, |
313 |
nom character varying(100) NOT NULL, |
314 |
telephone character varying(14), |
315 |
division integer NOT NULL, |
316 |
om_utilisateur integer, |
317 |
om_validite_debut date, |
318 |
om_validite_fin date, |
319 |
PRIMARY KEY ( instructeur ), |
320 |
FOREIGN KEY ( division ) REFERENCES division ( division ), |
321 |
FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur ) |
322 |
); |
323 |
|
324 |
-- Insertion des utilisateurs instructeurs dans la table instructeur |
325 |
INSERT INTO instructeur (instructeur,nom,telephone,division,om_utilisateur) |
326 |
(SELECT om_utilisateur,nom,telephone,1,om_utilisateur FROM om_utilisateur WHERE instructeur='Oui'); |
327 |
-- Mise a jour de la sequence |
328 |
SELECT setval('instructeur_seq',(SELECT MAX(instructeur) FROM instructeur)); |
329 |
|
330 |
|
331 |
-- Augment le om_parametre.libelle d'avoir 40 characteres |
332 |
ALTER TABLE om_parametre ALTER libelle TYPE character varying(40); |
333 |
|
334 |
-- Creation du parametre pour afficher ou non la division dans les dossiers |
335 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'afficher_division','false',1); |
336 |
|
337 |
-- Ajout des droits sur les tables d'organisation |
338 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'direction', '2'); |
339 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'division', '2'); |
340 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'instructeur', '2'); |
341 |
|
342 |
-- Modification de la clé étrangère dossier -> om_utilisateur par dossier -> instructeur |
343 |
ALTER TABLE dossier DROP CONSTRAINT dossier_instructeur_fkey; |
344 |
ALTER TABLE dossier ADD CONSTRAINT |
345 |
dossier_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
346 |
|
347 |
ALTER TABLE dossier ADD COLUMN division integer; |
348 |
ALTER TABLE dossier ADD CONSTRAINT |
349 |
dossier_division_fkey FOREIGN KEY (division) REFERENCES division(division); |
350 |
|
351 |
-- Ajout des parametres des liens dans la table om_parametre |
352 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'services_consultes_lien_interne', '',1); |
353 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'services_consultes_lien_externe', '',1); |
354 |
ALTER TABLE om_parametre ALTER COLUMN valeur TYPE character varying(150); |
355 |
|
356 |
|
357 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_code_barre', '2'); |
358 |
|
359 |
-- |
360 |
-- Ajout des tables arrondissement, quartier et lien_localisation_nature |
361 |
-- |
362 |
CREATE TABLE arrondissement ( |
363 |
arrondissement integer NOT NULL, |
364 |
libelle character varying(3) NOT NULL |
365 |
); |
366 |
|
367 |
ALTER TABLE ONLY arrondissement |
368 |
ADD CONSTRAINT arrondissement_pkey PRIMARY KEY (arrondissement); |
369 |
|
370 |
CREATE SEQUENCE arrondissement_seq |
371 |
INCREMENT 1 |
372 |
MINVALUE 1 |
373 |
MAXVALUE 9223372036854775807 |
374 |
START 1 |
375 |
CACHE 1; |
376 |
|
377 |
CREATE TABLE quartier ( |
378 |
quartier integer NOT NULL, |
379 |
arrondissement integer NOT NULL, |
380 |
code_impots character varying(3) NOT NULL, |
381 |
libelle character varying(40) NOT NULL |
382 |
); |
383 |
|
384 |
ALTER TABLE ONLY quartier |
385 |
ADD CONSTRAINT quartier_pkey PRIMARY KEY (quartier); |
386 |
ALTER TABLE ONLY quartier |
387 |
ADD CONSTRAINT quartier_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
388 |
|
389 |
CREATE SEQUENCE quartier_seq |
390 |
INCREMENT 1 |
391 |
MINVALUE 1 |
392 |
MAXVALUE 9223372036854775807 |
393 |
START 1 |
394 |
CACHE 1; |
395 |
|
396 |
CREATE TABLE lien_localisation_nature ( |
397 |
lien_localisation_nature integer NOT NULL, |
398 |
nature character varying(2), |
399 |
arrondissement integer, |
400 |
quartier integer , |
401 |
section varchar(2), |
402 |
instructeur integer NOT NULL |
403 |
); |
404 |
|
405 |
ALTER TABLE ONLY lien_localisation_nature |
406 |
ADD CONSTRAINT lien_localisation_nature_pkey PRIMARY KEY (lien_localisation_nature); |
407 |
ALTER TABLE ONLY lien_localisation_nature |
408 |
ADD CONSTRAINT lien_localisation_nature_nature_fkey FOREIGN KEY (nature) REFERENCES nature(nature); |
409 |
ALTER TABLE ONLY lien_localisation_nature |
410 |
ADD CONSTRAINT lien_localisation_nature_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
411 |
ALTER TABLE ONLY lien_localisation_nature |
412 |
ADD CONSTRAINT lien_localisation_nature_quartier_fkey FOREIGN KEY (quartier) REFERENCES quartier(quartier); |
413 |
ALTER TABLE ONLY lien_localisation_nature |
414 |
ADD CONSTRAINT lien_localisation_nature_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
415 |
|
416 |
CREATE SEQUENCE lien_localisation_nature_seq |
417 |
INCREMENT 1 |
418 |
MINVALUE 1 |
419 |
MAXVALUE 9223372036854775807 |
420 |
START 1 |
421 |
CACHE 1; |
422 |
|
423 |
-- Ajout des droits pour le retour des services |
424 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_encours', '2'); |
425 |
|
426 |
-- Suppression des colonnes inutiles dans la table om_utilisateur |
427 |
ALTER TABLE om_utilisateur DROP instructeur; |
428 |
|
429 |
ALTER TABLE om_utilisateur DROP telephone; |
430 |
|
431 |
-- Ajout des droits sur lien_service_om_utilisateur |
432 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_om_utilisateur', '2'); |
433 |
-- Ajout des droits pour le retour des services |
434 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_passee', '2'); |
435 |
|
436 |
-- Ajout des droits sur lien_localisation_nature |
437 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_localisation_nature', '2'); |
438 |
|
439 |
-- Ajout du droit pour changer l'état (lu/non lu) d'une consultation |
440 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_modifier_lu', '2'); |
441 |
|
442 |
-- Changement de taille du champs parcelle de la table parcelle et terrain |
443 |
ALTER TABLE parcelle ALTER COLUMN parcelle TYPE character varying(20); |
444 |
ALTER TABLE terrain ALTER COLUMN parcelle TYPE character varying(20); |
445 |
|
446 |
|
447 |
-- |
448 |
-- Messages |
449 |
-- |
450 |
|
451 |
-- create sequence for the message ID generation |
452 |
CREATE SEQUENCE messages_seq |
453 |
START WITH 1 |
454 |
INCREMENT BY 1 |
455 |
NO MINVALUE |
456 |
NO MAXVALUE |
457 |
CACHE 1; |
458 |
|
459 |
-- Create table dossier_message |
460 |
CREATE TABLE dossier_message ( |
461 |
message integer PRIMARY KEY DEFAULT nextval('messages_seq'), |
462 |
dossier character varying(12), |
463 |
type character varying(60), |
464 |
emetteur character varying(40), |
465 |
date_emission DATE NOT NULL, |
466 |
lu boolean default FALSE, |
467 |
contenu character varying(256), |
468 |
FOREIGN KEY ( dossier ) REFERENCES dossier ( dossier ) |
469 |
); |
470 |
ALTER SEQUENCE messages_seq OWNED BY dossier_message.message; |
471 |
|
472 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'menu_suivi', '2'); |
473 |
|
474 |
-- Droit de l'ajout forcé d'un instructeur |
475 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'dossier_modifier_instructeur', '2'); |
476 |
|
477 |
-- Module 1 |
478 |
CREATE TABLE dossier_autorisation_type ( |
479 |
dossier_autorisation_type integer, |
480 |
code character varying(20), |
481 |
libelle character varying(100), |
482 |
description text, |
483 |
confidentiel boolean default FALSE |
484 |
); |
485 |
|
486 |
ALTER TABLE ONLY dossier_autorisation_type |
487 |
ADD CONSTRAINT dossier_autorisation_type_pkey PRIMARY KEY (dossier_autorisation_type); |
488 |
|
489 |
CREATE SEQUENCE dossier_autorisation_type_seq |
490 |
INCREMENT 1 |
491 |
MINVALUE 1 |
492 |
MAXVALUE 9223372036854775807 |
493 |
START 1 |
494 |
CACHE 1; |
495 |
|
496 |
-- |
497 |
|
498 |
CREATE TABLE dossier_autorisation_type_detaille ( |
499 |
dossier_autorisation_type_detaille integer, |
500 |
code character varying(20), |
501 |
libelle character varying(100), |
502 |
description text, |
503 |
dossier_autorisation_type integer |
504 |
); |
505 |
|
506 |
ALTER TABLE ONLY dossier_autorisation_type_detaille |
507 |
ADD CONSTRAINT dossier_autorisation_type_detaille_pkey PRIMARY KEY (dossier_autorisation_type_detaille); |
508 |
ALTER TABLE ONLY dossier_autorisation_type_detaille |
509 |
ADD CONSTRAINT dossier_autorisation_type_detaille_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type); |
510 |
|
511 |
CREATE SEQUENCE dossier_autorisation_type_detaille_seq |
512 |
INCREMENT 1 |
513 |
MINVALUE 1 |
514 |
MAXVALUE 9223372036854775807 |
515 |
START 1 |
516 |
CACHE 1; |
517 |
|
518 |
-- |
519 |
|
520 |
CREATE TABLE dossier_instruction_type ( |
521 |
dossier_instruction_type integer, |
522 |
code character varying(20), |
523 |
libelle character varying(100), |
524 |
description text, |
525 |
dossier_autorisation_type_detaille integer, |
526 |
suffixe boolean default FALSE |
527 |
); |
528 |
|
529 |
ALTER TABLE ONLY dossier_instruction_type |
530 |
ADD CONSTRAINT dossier_instruction_type_pkey PRIMARY KEY (dossier_instruction_type); |
531 |
ALTER TABLE ONLY dossier_instruction_type |
532 |
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); |
533 |
|
534 |
CREATE SEQUENCE dossier_instruction_type_seq |
535 |
INCREMENT 1 |
536 |
MINVALUE 1 |
537 |
MAXVALUE 9223372036854775807 |
538 |
START 1 |
539 |
CACHE 1; |
540 |
|
541 |
-- |
542 |
|
543 |
CREATE TABLE demande_genre ( |
544 |
demande_genre integer, |
545 |
code character varying(20), |
546 |
libelle character varying(100), |
547 |
description text |
548 |
); |
549 |
|
550 |
ALTER TABLE ONLY demande_genre |
551 |
ADD CONSTRAINT demande_genre_pkey PRIMARY KEY (demande_genre); |
552 |
|
553 |
CREATE SEQUENCE demande_genre_seq |
554 |
INCREMENT 1 |
555 |
MINVALUE 1 |
556 |
MAXVALUE 9223372036854775807 |
557 |
START 1 |
558 |
CACHE 1; |
559 |
|
560 |
-- |
561 |
|
562 |
CREATE TABLE groupe ( |
563 |
groupe integer, |
564 |
code character varying(20), |
565 |
libelle character varying(100), |
566 |
description text, |
567 |
demande_genre integer |
568 |
); |
569 |
|
570 |
ALTER TABLE ONLY groupe |
571 |
ADD CONSTRAINT groupe_pkey PRIMARY KEY (groupe); |
572 |
ALTER TABLE ONLY groupe |
573 |
ADD CONSTRAINT groupe_demande_genre_fkey FOREIGN KEY (demande_genre) REFERENCES demande_genre(demande_genre); |
574 |
|
575 |
CREATE SEQUENCE groupe_seq |
576 |
INCREMENT 1 |
577 |
MINVALUE 1 |
578 |
MAXVALUE 9223372036854775807 |
579 |
START 1 |
580 |
CACHE 1; |
581 |
|
582 |
-- Ajout de clé étrangère à la table dossier_autorisation_type |
583 |
ALTER TABLE dossier_autorisation_type ADD COLUMN groupe integer; |
584 |
ALTER TABLE ONLY dossier_autorisation_type |
585 |
ADD CONSTRAINT dossier_autorisation_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe); |
586 |
|
587 |
--Demande nature |
588 |
|
589 |
CREATE TABLE demande_nature ( |
590 |
demande_nature integer, |
591 |
code character varying(20), |
592 |
libelle character varying(100), |
593 |
description text |
594 |
); |
595 |
|
596 |
ALTER TABLE ONLY demande_nature |
597 |
ADD CONSTRAINT demande_nature_pkey PRIMARY KEY (demande_nature); |
598 |
|
599 |
CREATE SEQUENCE demande_nature_seq |
600 |
INCREMENT 1 |
601 |
MINVALUE 1 |
602 |
MAXVALUE 9223372036854775807 |
603 |
START 1 |
604 |
CACHE 1; |
605 |
|
606 |
--Demande type |
607 |
|
608 |
CREATE TABLE demande_type ( |
609 |
demande_type integer, |
610 |
code character varying(20), |
611 |
libelle character varying(100), |
612 |
description text, |
613 |
demande_nature integer, |
614 |
groupe integer, |
615 |
dossier_instruction_type integer, |
616 |
dossier_autorisation_type_detaille integer, |
617 |
contraintes character varying(20), |
618 |
etats_dossier_autorisation_autorises character varying(100), |
619 |
qualification boolean, |
620 |
evenement integer |
621 |
); |
622 |
|
623 |
ALTER TABLE ONLY demande_type |
624 |
ADD CONSTRAINT demande_type_pkey PRIMARY KEY (demande_type); |
625 |
ALTER TABLE ONLY demande_type |
626 |
ADD CONSTRAINT demande_type_demande_nature_fkey FOREIGN KEY (demande_nature) REFERENCES demande_nature(demande_nature); |
627 |
ALTER TABLE ONLY demande_type |
628 |
ADD CONSTRAINT demande_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe); |
629 |
ALTER TABLE ONLY demande_type |
630 |
ADD CONSTRAINT demande_type_dossier_instruction_type_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type); |
631 |
ALTER TABLE ONLY demande_type |
632 |
ADD CONSTRAINT demande_type_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille); |
633 |
ALTER TABLE ONLY demande_type |
634 |
ADD CONSTRAINT demande_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement); |
635 |
|
636 |
CREATE SEQUENCE demande_type_seq |
637 |
INCREMENT 1 |
638 |
MINVALUE 1 |
639 |
MAXVALUE 9223372036854775807 |
640 |
START 1 |
641 |
CACHE 1; |
642 |
|
643 |
-- |
644 |
|
645 |
CREATE TABLE lien_evenement_dossier_autorisation_type ( |
646 |
lien_evenement_dossier_autorisation_type integer, |
647 |
evenement integer, |
648 |
dossier_autorisation_type integer |
649 |
); |
650 |
|
651 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
652 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_pkey PRIMARY KEY (lien_evenement_dossier_autorisation_type); |
653 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
654 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement); |
655 |
ALTER TABLE ONLY lien_evenement_dossier_autorisation_type |
656 |
ADD CONSTRAINT lien_evenement_dossier_autorisation_type_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type); |
657 |
|
658 |
CREATE SEQUENCE lien_evenement_dossier_autorisation_type_seq |
659 |
INCREMENT 1 |
660 |
MINVALUE 1 |
661 |
MAXVALUE 9223372036854775807 |
662 |
START 1 |
663 |
CACHE 1; |
664 |
|
665 |
-- |
666 |
|
667 |
CREATE TABLE autorite_competente ( |
668 |
autorite_competente integer, |
669 |
code character varying(20), |
670 |
libelle character varying(100), |
671 |
description text |
672 |
); |
673 |
|
674 |
ALTER TABLE ONLY autorite_competente |
675 |
ADD CONSTRAINT autorite_competente_pkey PRIMARY KEY (autorite_competente); |
676 |
|
677 |
CREATE SEQUENCE autorite_competente_seq |
678 |
INCREMENT 1 |
679 |
MINVALUE 1 |
680 |
MAXVALUE 9223372036854775807 |
681 |
START 1 |
682 |
CACHE 1; |
683 |
|
684 |
-- Ajout de clé étrangère à la table dossier_autorisation_type |
685 |
ALTER TABLE dossier ADD COLUMN autorite_competente integer; |
686 |
ALTER TABLE ONLY dossier |
687 |
ADD CONSTRAINT dossier_autorite_competente_fkey FOREIGN KEY (autorite_competente) REFERENCES autorite_competente(autorite_competente); |
688 |
|
689 |
-- Donnees des tables |
690 |
INSERT INTO dossier_autorisation_type(dossier_autorisation_type, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature; |
691 |
INSERT INTO dossier_autorisation_type_detaille(dossier_autorisation_type_detaille, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature; |
692 |
|
693 |
INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'URBA', 'Pôle Urbanisme', 'Responsabilité de la DDU'); |
694 |
INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'ERP', 'Pôle ERP', 'Responsabilité de la DGUP'); |
695 |
|
696 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ADS', 'Autorisation ADS', '',1); |
697 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CTX', 'Contentieux dans le domaine urbanisme', '',1); |
698 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CU', 'Changement d''usage', '',1); |
699 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'RU', 'Renseignement d''urbanisme', '',1); |
700 |
INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ERP', 'ERP', '',2); |
701 |
|
702 |
-- Table dossier_autorisation |
703 |
|
704 |
CREATE TABLE dossier_autorisation ( |
705 |
dossier_autorisation integer, |
706 |
nature character varying(2), |
707 |
dossier_autorisation_type_detaille integer, |
708 |
exercice integer, |
709 |
insee integer, |
710 |
terrain_references_cadastrales character varying(100), |
711 |
terrain_adresse_voie_numero integer, |
712 |
complement character varying(30), |
713 |
terrain_adresse_lieu_dit character varying(30), |
714 |
terrain_adresse_localite character varying(30), |
715 |
terrain_adresse_code_postal character varying(5), |
716 |
terrain_adresse_bp character varying(15), |
717 |
terrain_adresse_cedex character varying(15), |
718 |
terrain_superficie double precision, |
719 |
arrondissement integer, |
720 |
depot_initial date, |
721 |
etat character varying(20) |
722 |
); |
723 |
|
724 |
ALTER TABLE ONLY dossier_autorisation |
725 |
ADD CONSTRAINT dossier_autorisation_pkey PRIMARY KEY (dossier_autorisation); |
726 |
ALTER TABLE ONLY dossier_autorisation |
727 |
ADD CONSTRAINT dossier_autorisation_nature_fkey FOREIGN KEY (nature) REFERENCES nature(nature); |
728 |
ALTER TABLE ONLY dossier_autorisation |
729 |
ADD CONSTRAINT dossier_autorisation_type_detaille_fkey FOREIGN KEY (type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille); |
730 |
ALTER TABLE ONLY dossier_autorisation |
731 |
ADD CONSTRAINT dossier_autorisation_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
732 |
ALTER TABLE ONLY dossier_autorisation |
733 |
ADD CONSTRAINT dossier_autorisation_etat_fkey FOREIGN KEY (etat) REFERENCES etat(etat); |
734 |
|
735 |
CREATE SEQUENCE dossier_autorisation_seq |
736 |
INCREMENT 1 |
737 |
MINVALUE 1 |
738 |
MAXVALUE 9223372036854775807 |
739 |
START 1 |
740 |
CACHE 1; |
741 |
|
742 |
-- Table Demande |
743 |
|
744 |
CREATE TABLE demande ( |
745 |
demande integer, |
746 |
dossier_autorisation_type_detaille integer, |
747 |
demande_type integer, |
748 |
dossier_instruction character varying(12), |
749 |
dossier_autorisation integer, |
750 |
date_demande date, |
751 |
terrain_references_cadastrales character varying(100), |
752 |
terrain_adresse_voie_numero integer, |
753 |
complement character varying(30), |
754 |
terrain_adresse_lieu_dit character varying(30), |
755 |
terrain_adresse_localite character varying(30), |
756 |
terrain_adresse_code_postal character varying(5), |
757 |
terrain_adresse_bp character varying(15), |
758 |
terrain_adresse_cedex character varying(15), |
759 |
terrain_superficie double precision, |
760 |
nombre_lots integer |
761 |
); |
762 |
|
763 |
ALTER TABLE ONLY demande |
764 |
ADD CONSTRAINT demande_pkey PRIMARY KEY (demande); |
765 |
ALTER TABLE ONLY demande |
766 |
ADD CONSTRAINT demande_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille); |
767 |
ALTER TABLE ONLY demande |
768 |
ADD CONSTRAINT demande_demande_type_fkey FOREIGN KEY (demande_type) REFERENCES demande_type(demande_type); |
769 |
ALTER TABLE ONLY demande |
770 |
ADD CONSTRAINT demande_dossier_instruction_fkey FOREIGN KEY (dossier_instruction) REFERENCES dossier(dossier); |
771 |
ALTER TABLE ONLY demande |
772 |
ADD CONSTRAINT demande_dossier_autorisation_fkey FOREIGN KEY (dossier_autorisation) REFERENCES dossier_autorisation(dossier_autorisation); |
773 |
|
774 |
CREATE SEQUENCE demande_seq |
775 |
INCREMENT 1 |
776 |
MINVALUE 1 |
777 |
MAXVALUE 9223372036854775807 |
778 |
START 1 |
779 |
CACHE 1; |
780 |
|
781 |
-- Table Demandeur |
782 |
|
783 |
CREATE TABLE demandeur ( |
784 |
demandeur integer, |
785 |
type_demandeur character varying(40), |
786 |
particulier_civilite character varying(10), |
787 |
particulier_nom character varying(40), |
788 |
particulier_prenom character varying(40), |
789 |
particulier_date_naissance date, |
790 |
particulier_commune_naissance character varying(30), |
791 |
particulier_departement_naissance character varying(80), |
792 |
personne_morale_denomination character varying(15), |
793 |
personne_morale_raison_sociale character varying(15), |
794 |
personne_morale_siret character varying(15), |
795 |
personne_morale_categorie_juridique character varying(15), |
796 |
personne_morale_civilite character varying(10), |
797 |
personne_morale_nom character varying(40), |
798 |
personne_morale_prenom character varying(40), |
799 |
numero character varying(5), |
800 |
voie character varying(40), |
801 |
complement character varying(39), |
802 |
lieu_dit character varying(39), |
803 |
localite character varying(30), |
804 |
code_postal character varying(5), |
805 |
bp character varying(5), |
806 |
cedex character varying(5), |
807 |
pays character varying(40), |
808 |
division_territoriale character varying(40), |
809 |
telephone_fixe character varying(14), |
810 |
telephone_mobile character varying(14), |
811 |
indicatif character varying(5), |
812 |
courriel character varying(40), |
813 |
notification boolean, |
814 |
frequent boolean |
815 |
); |
816 |
|
817 |
ALTER TABLE ONLY demandeur |
818 |
ADD CONSTRAINT demandeur_pkey PRIMARY KEY (demandeur); |
819 |
ALTER TABLE ONLY demandeur |
820 |
ADD CONSTRAINT demandeur_particulier_civilite_fkey FOREIGN KEY (particulier_civilite) REFERENCES civilite(civilite); |
821 |
ALTER TABLE ONLY demandeur |
822 |
ADD CONSTRAINT demandeur_personne_morale_civilite_fkey FOREIGN KEY (personne_morale_civilite) REFERENCES civilite(civilite); |
823 |
|
824 |
CREATE SEQUENCE demandeur_seq |
825 |
INCREMENT 1 |
826 |
MINVALUE 1 |
827 |
MAXVALUE 9223372036854775807 |
828 |
START 1 |
829 |
CACHE 1; |
830 |
|
831 |
-- Table Lien demande demandeur |
832 |
|
833 |
CREATE TABLE lien_demande_demandeur ( |
834 |
lien_demande_demandeur integer, |
835 |
petitionnaire_principal boolean, |
836 |
demande integer, |
837 |
demandeur integer |
838 |
); |
839 |
|
840 |
ALTER TABLE ONLY lien_demande_demandeur |
841 |
ADD CONSTRAINT lien_demande_demandeur_pkey PRIMARY KEY (lien_demande_demandeur); |
842 |
ALTER TABLE ONLY lien_demande_demandeur |
843 |
ADD CONSTRAINT lien_demande_demandeur_demande_fkey FOREIGN KEY (demande) REFERENCES demande(demande); |
844 |
ALTER TABLE ONLY lien_demande_demandeur |
845 |
ADD CONSTRAINT lien_demande_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur); |
846 |
|
847 |
CREATE SEQUENCE lien_demande_demandeur_seq |
848 |
INCREMENT 1 |
849 |
MINVALUE 1 |
850 |
MAXVALUE 9223372036854775807 |
851 |
START 1 |
852 |
CACHE 1; |
853 |
|
854 |
-- Table lot |
855 |
|
856 |
CREATE TABLE lot ( |
857 |
lot integer, |
858 |
dossier_instruction character varying(12) |
859 |
); |
860 |
|
861 |
ALTER TABLE ONLY lot |
862 |
ADD CONSTRAINT lot_pkey PRIMARY KEY (lot); |
863 |
ALTER TABLE ONLY lot |
864 |
ADD CONSTRAINT lot_dossier_instruction_fkey FOREIGN KEY (dossier_instruction) REFERENCES dossier(dossier); |
865 |
|
866 |
CREATE SEQUENCE lot_seq |
867 |
INCREMENT 1 |
868 |
MINVALUE 1 |
869 |
MAXVALUE 9223372036854775807 |
870 |
START 1 |
871 |
CACHE 1; |
872 |
|
873 |
-- Table lien_lot_demandeur |
874 |
|
875 |
CREATE TABLE lien_lot_demandeur ( |
876 |
lien_lot_demandeur integer, |
877 |
lot integer, |
878 |
demandeur integer |
879 |
); |
880 |
|
881 |
ALTER TABLE ONLY lien_lot_demandeur |
882 |
ADD CONSTRAINT lien_lot_demandeur_pkey PRIMARY KEY (lien_lot_demandeur); |
883 |
ALTER TABLE ONLY lien_lot_demandeur |
884 |
ADD CONSTRAINT lien_lot_demandeur_lot_fkey FOREIGN KEY (lot) REFERENCES lot(lot); |
885 |
ALTER TABLE ONLY lien_lot_demandeur |
886 |
ADD CONSTRAINT lien_lot_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur); |
887 |
|
888 |
CREATE SEQUENCE lien_lot_demandeur_seq |
889 |
INCREMENT 1 |
890 |
MINVALUE 1 |
891 |
MAXVALUE 9223372036854775807 |
892 |
START 1 |
893 |
CACHE 1; |
894 |
|
895 |
|
896 |
--- |
897 |
--- Nouvelle gestion des tableaux de bord |
898 |
--- |
899 |
|
900 |
CREATE TABLE om_dashboard ( |
901 |
om_dashboard integer NOT NULL, |
902 |
om_profil integer NOT NULL, |
903 |
bloc character varying(10) NOT NULL, |
904 |
position integer, |
905 |
om_widget integer NOT NULL |
906 |
); |
907 |
|
908 |
ALTER TABLE ONLY om_dashboard |
909 |
ADD CONSTRAINT om_dashboard_pkey PRIMARY KEY (om_dashboard); |
910 |
ALTER TABLE ONLY om_dashboard |
911 |
ADD CONSTRAINT om_dashboard_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil); |
912 |
ALTER TABLE ONLY om_dashboard |
913 |
ADD CONSTRAINT om_dashboard_om_widget_fkey FOREIGN KEY (om_widget) REFERENCES om_widget(om_widget); |
914 |
|
915 |
CREATE SEQUENCE om_dashboard_seq |
916 |
START WITH 1 |
917 |
INCREMENT BY 1 |
918 |
NO MINVALUE |
919 |
NO MAXVALUE |
920 |
CACHE 1; |
921 |
|
922 |
SELECT pg_catalog.setval('om_dashboard_seq', 1, false); |
923 |
|
924 |
ALTER TABLE om_widget |
925 |
DROP CONSTRAINT om_widget_om_profil_fkey; |
926 |
|
927 |
ALTER TABlE om_widget DROP COLUMN om_profil; |
928 |
|
929 |
ALTER TABLE om_widget ADD COLUMN "type" character varying(40) NOT NULL DEFAULT 'web'::character varying; |
930 |
ALTER TABLE om_widget ALTER COLUMN "lien" SET DEFAULT ''::character varying; |
931 |
ALTER TABLE om_widget ALTER COLUMN "texte" SET DEFAULT ''::text; |
932 |
|
933 |
-- Modification de la table civilite |
934 |
ALTER TABLE dossier DROP CONSTRAINT dossier_delegataire_civilite_fkey; |
935 |
ALTER TABLE dossier DROP CONSTRAINT dossier_demandeur_civilite_fkey; |
936 |
ALTER TABLE proprietaire DROP CONSTRAINT proprietaire_civilite_fkey; |
937 |
ALTER TABLE demandeur DROP CONSTRAINT demandeur_particulier_civilite_fkey; |
938 |
ALTER TABLE demandeur DROP CONSTRAINT demandeur_personne_morale_civilite_fkey; |
939 |
ALTER TABLE civilite DROP CONSTRAINT civilite_pkey; |
940 |
|
941 |
ALTER TABLE dossier RENAME COLUMN delegataire_civilite TO delegataire_civilite_old; |
942 |
ALTER TABLE dossier RENAME COLUMN demandeur_civilite TO demandeur_civilite_old; |
943 |
ALTER TABLE proprietaire RENAME COLUMN civilite TO civilite_old; |
944 |
ALTER TABLE demandeur RENAME COLUMN particulier_civilite TO particulier_civilite_old; |
945 |
ALTER TABLE demandeur RENAME COLUMN personne_morale_civilite TO personne_morale_civilite_old; |
946 |
ALTER TABLE civilite RENAME COLUMN civilite TO civilite_old; |
947 |
|
948 |
CREATE SEQUENCE civilite_seq |
949 |
START WITH 1 |
950 |
INCREMENT BY 1 |
951 |
NO MAXVALUE |
952 |
NO MINVALUE |
953 |
CACHE 1; |
954 |
|
955 |
ALTER TABLE civilite ADD COLUMN civilite integer NOT NULL DEFAULT nextval('civilite_seq'::regclass); |
956 |
ALTER TABLE dossier ADD COLUMN delegataire_civilite integer; |
957 |
ALTER TABLE dossier ADD COLUMN demandeur_civilite integer; |
958 |
ALTER TABLE proprietaire ADD COLUMN civilite integer; |
959 |
ALTER TABLE demandeur ADD COLUMN particulier_civilite integer; |
960 |
ALTER TABLE demandeur ADD COLUMN personne_morale_civilite integer; |
961 |
|
962 |
UPDATE dossier SET delegataire_civilite=(select civilite.civilite from civilite where delegataire_civilite_old=civilite.civilite_old); |
963 |
UPDATE dossier SET demandeur_civilite=(select civilite.civilite from civilite where demandeur_civilite_old=civilite.civilite_old); |
964 |
UPDATE proprietaire SET civilite=(select civilite.civilite from civilite where civilite_old=civilite.civilite_old); |
965 |
UPDATE demandeur SET particulier_civilite=(select civilite.civilite from civilite where particulier_civilite_old=civilite.civilite_old); |
966 |
UPDATE demandeur SET personne_morale_civilite=(select civilite.civilite from civilite where personne_morale_civilite_old=civilite.civilite_old); |
967 |
|
968 |
ALTER TABLE civilite ADD COLUMN libelle character varying(100); |
969 |
ALTER TABLE civilite ADD COLUMN om_validite_debut date; |
970 |
ALTER TABLE civilite ADD COLUMN om_validite_fin date; |
971 |
|
972 |
|
973 |
ALTER TABLE civilite RENAME COLUMN civilite_old TO code; |
974 |
ALTER TABLE dossier DROP COLUMN delegataire_civilite_old; |
975 |
ALTER TABLE dossier DROP COLUMN demandeur_civilite_old; |
976 |
ALTER TABLE proprietaire DROP COLUMN civilite_old; |
977 |
ALTER TABLE demandeur DROP COLUMN particulier_civilite_old; |
978 |
ALTER TABLE demandeur DROP COLUMN personne_morale_civilite_old; |
979 |
|
980 |
ALTER TABLE ONLY civilite |
981 |
ADD CONSTRAINT civilite_pkey PRIMARY KEY (civilite); |
982 |
|
983 |
ALTER TABLE ONLY dossier |
984 |
ADD CONSTRAINT dossier_delegataire_civilite_fkey FOREIGN KEY (delegataire_civilite) REFERENCES civilite(civilite); |
985 |
ALTER TABLE ONLY dossier |
986 |
ADD CONSTRAINT dossier_demandeur_civilite_fkey FOREIGN KEY (demandeur_civilite) REFERENCES civilite(civilite); |
987 |
ALTER TABLE ONLY proprietaire |
988 |
ADD CONSTRAINT proprietaire_civilite_fkey FOREIGN KEY (civilite) REFERENCES civilite(civilite); |
989 |
ALTER TABLE ONLY demandeur |
990 |
ADD CONSTRAINT demandeur_particulier_civilite_fkey FOREIGN KEY (particulier_civilite) REFERENCES civilite(civilite); |
991 |
ALTER TABLE ONLY demandeur |
992 |
ADD CONSTRAINT demandeur_personne_morale_civilite_fkey FOREIGN KEY (personne_morale_civilite) REFERENCES civilite(civilite); |
993 |
|
994 |
ALTER SEQUENCE civilite_seq OWNED BY civilite.civilite; |
995 |
|
996 |
ALTER TABLE civilite ALTER COLUMN civilite DROP DEFAULT; |
997 |
|
998 |
UPDATE civilite SET libelle='Monsieur Madame' WHERE civilite = 1 ; |
999 |
UPDATE civilite SET libelle='Mademoiselle' WHERE civilite = 2 ; |
1000 |
UPDATE civilite SET libelle='Madame' WHERE civilite = 3 ; |
1001 |
UPDATE civilite SET libelle='Monsieur' WHERE civilite = 4 ; |
1002 |
|
1003 |
-- Table Lien dossier_autorisation demandeur |
1004 |
|
1005 |
CREATE TABLE lien_dossier_autorisation_demandeur ( |
1006 |
lien_dossier_autorisation_demandeur integer, |
1007 |
petitionnaire_principal boolean, |
1008 |
dossier_autorisation integer, |
1009 |
demandeur integer |
1010 |
); |
1011 |
|
1012 |
ALTER TABLE ONLY lien_dossier_autorisation_demandeur |
1013 |
ADD CONSTRAINT lien_dossier_autorisation_demandeur_pkey PRIMARY KEY (lien_dossier_autorisation_demandeur); |
1014 |
ALTER TABLE ONLY lien_dossier_autorisation_demandeur |
1015 |
ADD CONSTRAINT lien_dossier_autorisation_demandeur_demande_fkey FOREIGN KEY (dossier_autorisation) REFERENCES dossier_autorisation(dossier_autorisation); |
1016 |
ALTER TABLE ONLY lien_dossier_autorisation_demandeur |
1017 |
ADD CONSTRAINT lien_dossier_autorisation_demandeur_demandeur_fkey FOREIGN KEY (demandeur) REFERENCES demandeur(demandeur); |
1018 |
|
1019 |
CREATE SEQUENCE lien_dossier_autorisation_demandeur_seq |
1020 |
INCREMENT 1 |
1021 |
MINVALUE 1 |
1022 |
MAXVALUE 9223372036854775807 |
1023 |
START 1 |
1024 |
CACHE 1; |
1025 |
|
1026 |
-- Ajout du champ à qualifier -- |
1027 |
ALTER TABLE dossier ADD COLUMN a_qualifier boolean; |