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' |
-- Ajout de la table 'service_categorie' |
28 |
-- |
-- |
29 |
CREATE TABLE service_categorie ( |
CREATE TABLE service_categorie ( |
169 |
|
|
170 |
ALTER TABLE avis_consultation ADD COLUMN avis_consultation integer NOT NULL DEFAULT nextval('avis_consultation_seq'::regclass); |
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 |
INSERT INTO avis_consultation(avis_old, libelle) SELECT avis, libelle |
172 |
FROM avis; |
FROM avis_consultation_tmp; |
173 |
|
|
174 |
|
|
175 |
ALTER TABLE ONLY avis_decision |
ALTER TABLE ONLY avis_decision |
193 |
ALTER TABLE dossier ADD COLUMN avis_decision integer; |
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); |
UPDATE consultation SET avis_consultation=(select avis_consultation.avis_consultation from avis_consultation where avis=avis_consultation.avis_old); |
200 |
|
|
201 |
-- |
-- |
228 |
ALTER TABLE avis_decision DROP COLUMN avis_old; |
ALTER TABLE avis_decision DROP COLUMN avis_old; |
229 |
ALTER TABLE avis_consultation DROP COLUMN avis_old; |
ALTER TABLE avis_consultation DROP COLUMN avis_old; |
230 |
DROP TABLE avis; |
DROP TABLE avis; |
231 |
|
DROP TABLE avis_consultation_tmp; |
232 |
|
|
233 |
-- |
-- |
234 |
-- Ajout des droits sur l'objet consultation_encours |
-- Ajout des droits sur l'objet consultation_encours |
256 |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_service_categorie', '4'); |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_service_categorie', '4'); |
257 |
|
|
258 |
ALTER TABLE consultation ALTER service SET NOT NULL; |
ALTER TABLE consultation ALTER service SET NOT NULL; |
259 |
ALTER TABLE dossier ADD COLUMN enjeu boolean; |
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); |
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); |
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_tous_retours', 4); |
264 |
|
|
275 |
CREATE TABLE direction ( |
CREATE TABLE direction ( |
276 |
direction integer NOT NULL, |
direction integer NOT NULL, |
277 |
code character varying(20) NOT NULL, |
code character varying(20) NOT NULL, |
278 |
libelle character varying(40) NOT NULL, |
libelle character varying(100) NOT NULL, |
279 |
description text, |
description text, |
280 |
chef character varying(30) NOT NULL, |
chef character varying(100) NOT NULL, |
281 |
|
om_validite_debut date, |
282 |
|
om_validite_fin date, |
283 |
PRIMARY KEY (direction) |
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'); |
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 |
CREATE SEQUENCE division_seq |
289 |
START WITH 1 |
START WITH 1 |
295 |
CREATE TABLE division ( |
CREATE TABLE division ( |
296 |
division integer NOT NULL, |
division integer NOT NULL, |
297 |
code character varying(20) NOT NULL, |
code character varying(20) NOT NULL, |
298 |
libelle character varying(40) NOT NULL, |
libelle character varying(100) NOT NULL, |
299 |
description text, |
description text, |
300 |
chef character varying(30) NOT NULL, |
chef character varying(100) NOT NULL, |
301 |
direction integer NOT NULL, |
direction integer NOT NULL, |
302 |
|
om_validite_debut date, |
303 |
|
om_validite_fin date, |
304 |
PRIMARY KEY (division), |
PRIMARY KEY (division), |
305 |
FOREIGN KEY ( direction ) REFERENCES direction ( direction ) |
FOREIGN KEY ( direction ) REFERENCES direction ( direction ) |
306 |
); |
); |
307 |
|
|
308 |
INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1); |
INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1, NULL, NULL); |
309 |
|
|
310 |
CREATE SEQUENCE instructeur_seq |
CREATE SEQUENCE instructeur_seq |
311 |
START WITH 1 |
START WITH 1 |
316 |
|
|
317 |
CREATE TABLE instructeur ( |
CREATE TABLE instructeur ( |
318 |
instructeur integer NOT NULL, |
instructeur integer NOT NULL, |
319 |
nom character varying(30) NOT NULL, |
nom character varying(100) NOT NULL, |
320 |
telephone character varying(14), |
telephone character varying(14), |
321 |
division integer NOT NULL, |
division integer NOT NULL, |
322 |
om_utilisateur integer, |
om_utilisateur integer, |
323 |
|
om_validite_debut date, |
324 |
|
om_validite_fin date, |
325 |
PRIMARY KEY ( instructeur ), |
PRIMARY KEY ( instructeur ), |
326 |
FOREIGN KEY ( division ) REFERENCES division ( division ), |
FOREIGN KEY ( division ) REFERENCES division ( division ), |
327 |
FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur ) |
FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur ) |
351 |
INSERT INTO om_parametre VALUES (nextval('om_parametre_seq'::regclass),'lien_externe', '',1); |
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); |
ALTER TABLE om_parametre ALTER COLUMN valeur TYPE character varying(150); |
353 |
|
|
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_code_barre', '2'); |
|
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 TABLE quartier ( |
369 |
|
quartier integer NOT NULL, |
370 |
|
arrondissement integer NOT NULL, |
371 |
|
code_impots character varying(3) NOT NULL, |
372 |
|
libelle character varying(40) NOT NULL |
373 |
|
); |
374 |
|
|
375 |
|
ALTER TABLE ONLY quartier |
376 |
|
ADD CONSTRAINT quartier_pkey PRIMARY KEY (quartier); |
377 |
|
ALTER TABLE ONLY quartier |
378 |
|
ADD CONSTRAINT quartier_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
379 |
|
|
380 |
|
CREATE TABLE lien_localisation_nature ( |
381 |
|
lien_localisation_nature integer NOT NULL, |
382 |
|
nature character varying(2), |
383 |
|
arrondissement integer, |
384 |
|
quartier integer , |
385 |
|
section varchar(2), |
386 |
|
instructeur integer NOT NULL |
387 |
|
); |
388 |
|
|
389 |
|
ALTER TABLE ONLY lien_localisation_nature |
390 |
|
ADD CONSTRAINT lien_localisation_nature_pkey PRIMARY KEY (lien_localisation_nature); |
391 |
|
ALTER TABLE ONLY lien_localisation_nature |
392 |
|
ADD CONSTRAINT lien_localisation_nature_nature_fkey FOREIGN KEY (nature) REFERENCES nature(nature); |
393 |
|
ALTER TABLE ONLY lien_localisation_nature |
394 |
|
ADD CONSTRAINT lien_localisation_nature_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement); |
395 |
|
ALTER TABLE ONLY lien_localisation_nature |
396 |
|
ADD CONSTRAINT lien_localisation_nature_quartier_fkey FOREIGN KEY (quartier) REFERENCES quartier(quartier); |
397 |
|
ALTER TABLE ONLY lien_localisation_nature |
398 |
|
ADD CONSTRAINT lien_localisation_nature_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur); |
399 |
|
|
400 |
|
-- Ajout des droits pour le retour des services |
401 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_encours', '2'); |
402 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_retour_service', '2'); |
403 |
|
|
404 |
|
-- Suppression des colonnes inutiles dans la table om_utilisateur |
405 |
|
ALTER TABLE om_utilisateur DROP instructeur; |
406 |
|
|
407 |
|
ALTER TABLE om_utilisateur DROP telephone; |
408 |
|
|
409 |
|
-- Ajout des droits sur lien_service_om_utilisateur |
410 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_om_utilisateur', '2'); |
411 |
|
-- Ajout des droits pour le retour des services |
412 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_passee', '2'); |
413 |
|
|
414 |
|
-- Ajout des droits sur lien_localisation_nature |
415 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_localisation_nature', '2'); |
416 |
|
|
417 |
|
-- Ajout du droit pour changer l'état (lu/non lu) d'une consultation |
418 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_modifier_lu', '2'); |
419 |
|
|
420 |
|
-- Changement de taille du champs parcelle de la table parcelle et terrain |
421 |
|
ALTER TABLE parcelle ALTER COLUMN parcelle TYPE character varying(20); |
422 |
|
ALTER TABLE terrain ALTER COLUMN parcelle TYPE character varying(20); |
423 |
|
|
424 |
|
|
425 |
|
-- |
426 |
|
-- Messages |
427 |
|
-- |
428 |
|
|
429 |
|
-- create sequence for the message ID generation |
430 |
|
CREATE SEQUENCE messages_seq |
431 |
|
START WITH 1 |
432 |
|
INCREMENT BY 1 |
433 |
|
NO MINVALUE |
434 |
|
NO MAXVALUE |
435 |
|
CACHE 1; |
436 |
|
|
437 |
|
-- Create table messages |
438 |
|
CREATE TABLE messages ( |
439 |
|
message integer PRIMARY KEY DEFAULT nextval('messages_seq'), |
440 |
|
dossier character varying(12), |
441 |
|
type character varying(60), |
442 |
|
emetteur character varying(40), |
443 |
|
date_emission DATE NOT NULL, |
444 |
|
lu boolean default FALSE, |
445 |
|
FOREIGN KEY ( dossier ) REFERENCES dossier ( dossier ) -- add this |
446 |
|
); |
447 |
|
ALTER SEQUENCE messages_seq OWNED BY messages.message; |
448 |
|
|
449 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'menu_suivi', '2'); |
450 |
|
|
451 |
|
-- Droit de l'ajout forcé d'un instructeur |
452 |
|
INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'dossier_modifier_instructeur', '2'); |