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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 622 - (hide annotations)
Wed Nov 7 14:41:45 2012 UTC (12 years, 2 months ago) by vpihour
File size: 24040 byte(s)
Données concernant les arrondissements et les quartiers de Marseille

1 vpihour 486 --
2 mlimic 560 -- 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 vpihour 486 -- 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 vpihour 500 ALTER TABLE service ADD COLUMN notification_email boolean;
67 vpihour 486 ALTER TABLE service ADD COLUMN om_validite_debut date;
68     ALTER TABLE service ADD COLUMN om_validite_fin date;
69 vpihour 510 ALTER TABLE service ADD COLUMN type_consultation varchar(70) NOT NULL DEFAULT 'avec_avis_attendu';
70 vpihour 486
71 vpihour 492 ALTER TABLE service RENAME COLUMN service_old TO abrege;
72 vpihour 486 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 vpihour 487 FROM avis;
169 vpihour 486
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 mlimic 560 FROM avis_consultation_tmp;
173 vpihour 486
174 vpihour 487
175 vpihour 486 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 vpihour 487 ALTER SEQUENCE avis_consultation_seq OWNED BY avis_consultation.avis_consultation;
180     ALTER SEQUENCE avis_decision_seq OWNED BY avis_decision.avis_decision;
181 vpihour 486 ALTER TABLE avis_decision ALTER COLUMN avis_decision DROP DEFAULT;
182     ALTER TABLE avis_consultation ALTER COLUMN avis_consultation DROP DEFAULT;
183    
184 vpihour 487 -- 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 mlimic 608
197    
198    
199 vpihour 487 UPDATE consultation SET avis_consultation=(select avis_consultation.avis_consultation from avis_consultation where avis=avis_consultation.avis_old);
200    
201 vpihour 486 --
202     -- Modification de la table 'consultation'
203     --
204 vpihour 497 ALTER TABLE consultation ADD COLUMN date_reception date;
205     ALTER TABLE consultation ADD COLUMN motivation text DEFAULT '';
206 vpihour 486 ALTER TABLE consultation ADD COLUMN fichier character varying(100);
207     ALTER TABLE consultation ADD COLUMN lu boolean;
208    
209    
210 vpihour 500
211 vpihour 487 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 vpihour 489 ALTER TABLE avis_decision DROP COLUMN avis_old;
229     ALTER TABLE avis_consultation DROP COLUMN avis_old;
230     DROP TABLE avis;
231 mlimic 560 DROP TABLE avis_consultation_tmp;
232 vpihour 497
233     --
234 nhaye 498 -- Ajout des droits sur l'objet consultation_encours
235     --
236    
237    
238 nhaye 509 INSERT INTO om_widget VALUES (1, 1, 'Retours de consultations', '../scr/tab.php?obj=consultation_mes_retours', '<script type=''text/javascript''>
239 nhaye 498 $.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 vpihour 497 -- Ajout des droits sur les nouvelles tables
252     --
253 nhaye 498 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 nhaye 506
258     ALTER TABLE consultation ALTER service SET NOT NULL;
259 mlimic 608 ALTER TABLE dossier ADD COLUMN enjeu_erp boolean;
260     ALTER TABLE dossier ADD COLUMN enjeu_urba boolean;
261    
262 nhaye 509 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_mes_retours', 4);
263 vpihour 510 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_tous_retours', 4);
264 nhaye 514
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 nhaye 603 libelle character varying(100) NOT NULL,
279 nhaye 514 description text,
280 nhaye 605 chef character varying(100) NOT NULL,
281 nhaye 603 om_validite_debut date,
282     om_validite_fin date,
283 nhaye 514 PRIMARY KEY (direction)
284     );
285    
286 nhaye 603 INSERT INTO direction VALUES (nextval('direction_seq'::regclass),'ADS', 'Direction ADS', 'Direction des autorisations des droits du sol', 'Mme Dupont', NULL, NULL);
287 nhaye 514
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 nhaye 603 libelle character varying(100) NOT NULL,
299 nhaye 514 description text,
300 nhaye 603 chef character varying(100) NOT NULL,
301 nhaye 514 direction integer NOT NULL,
302 nhaye 603 om_validite_debut date,
303     om_validite_fin date,
304 nhaye 514 PRIMARY KEY (division),
305     FOREIGN KEY ( direction ) REFERENCES direction ( direction )
306     );
307    
308 nhaye 603 INSERT INTO division VALUES (nextval('division_seq'::regclass),'Defaut', 'Division par defaut', '', 'Mme Dupont',1, NULL, NULL);
309 nhaye 514
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 nhaye 603 nom character varying(100) NOT NULL,
320 nhaye 514 telephone character varying(14),
321     division integer NOT NULL,
322     om_utilisateur integer,
323 nhaye 603 om_validite_debut date,
324     om_validite_fin date,
325 nhaye 514 PRIMARY KEY ( instructeur ),
326     FOREIGN KEY ( division ) REFERENCES division ( division ),
327     FOREIGN KEY ( om_utilisateur ) REFERENCES om_utilisateur ( om_utilisateur )
328     );
329    
330 nhaye 519 -- Insertion des utilisateurs instructeurs dans la table instructeur
331 nhaye 514 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 nhaye 519 -- Mise a jour de la sequence
334     SELECT setval('instructeur_seq',(SELECT MAX(instructeur) FROM instructeur));
335 nhaye 517
336 nhaye 519 -- 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 nhaye 517
339 nhaye 519 -- 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 nhaye 520
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 nhaye 532
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 nhaye 538
354 vpihour 555
355 nhaye 544 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'avis_code_barre', '2');
356    
357 vpihour 555 --
358     -- Ajout des tables arrondissement, quartier et lien_localisation_nature
359     --
360     CREATE TABLE arrondissement (
361     arrondissement integer NOT NULL,
362 vpihour 575 libelle character varying(3) NOT NULL
363 vpihour 555 );
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 vpihour 558 arrondissement integer NOT NULL,
371 vpihour 555 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 vpihour 558 ALTER TABLE ONLY quartier
378     ADD CONSTRAINT quartier_arrondissement_fkey FOREIGN KEY (arrondissement) REFERENCES arrondissement(arrondissement);
379 vpihour 555
380     CREATE TABLE lien_localisation_nature (
381     lien_localisation_nature integer NOT NULL,
382 vpihour 558 nature character varying(2),
383     arrondissement integer,
384     quartier integer ,
385 vpihour 563 section varchar(2),
386     instructeur integer NOT NULL
387 vpihour 555 );
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 vpihour 563 ALTER TABLE ONLY lien_localisation_nature
398     ADD CONSTRAINT lien_localisation_nature_instructeur_fkey FOREIGN KEY (instructeur) REFERENCES instructeur(instructeur);
399 vpihour 555
400 vpihour 617 CREATE SEQUENCE lien_localisation_nature_seq
401     INCREMENT 1
402     MINVALUE 1
403     MAXVALUE 9223372036854775807
404     START 1
405     CACHE 1;
406    
407 nhaye 544 -- Ajout des droits pour le retour des services
408 nhaye 571 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_encours', '2');
409 nhaye 545 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_retour_service', '2');
410    
411     -- Suppression des colonnes inutiles dans la table om_utilisateur
412 nhaye 546 ALTER TABLE om_utilisateur DROP instructeur;
413 vpihour 555
414 nhaye 549 ALTER TABLE om_utilisateur DROP telephone;
415    
416     -- Ajout des droits sur lien_service_om_utilisateur
417 nhaye 554 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_service_om_utilisateur', '2');
418     -- Ajout des droits pour le retour des services
419 nhaye 571 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'demande_avis_passee', '2');
420 vpihour 558
421     -- Ajout des droits sur lien_localisation_nature
422     INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'lien_localisation_nature', '2');
423 nhaye 561
424     -- Ajout du droit pour changer l'état (lu/non lu) d'une consultation
425     INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'consultation_modifier_lu', '2');
426 vpihour 575
427     -- Changement de taille du champs parcelle de la table parcelle et terrain
428     ALTER TABLE parcelle ALTER COLUMN parcelle TYPE character varying(20);
429     ALTER TABLE terrain ALTER COLUMN parcelle TYPE character varying(20);
430    
431 mlimic 581
432     --
433     -- Messages
434     --
435    
436     -- create sequence for the message ID generation
437 mlimic 586 CREATE SEQUENCE messages_seq
438 mlimic 581 START WITH 1
439     INCREMENT BY 1
440     NO MINVALUE
441     NO MAXVALUE
442     CACHE 1;
443    
444     -- Create table messages
445 mlimic 586 CREATE TABLE messages (
446     message integer PRIMARY KEY DEFAULT nextval('messages_seq'),
447 mlimic 581 dossier character varying(12),
448     type character varying(60),
449     emetteur character varying(40),
450 mlimic 599 date_emission DATE NOT NULL,
451 mlimic 586 lu boolean default FALSE,
452     FOREIGN KEY ( dossier ) REFERENCES dossier ( dossier ) -- add this
453 mlimic 581 );
454 mlimic 586 ALTER SEQUENCE messages_seq OWNED BY messages.message;
455 nhaye 583
456     INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'menu_suivi', '2');
457 vpihour 593
458     -- Droit de l'ajout forcé d'un instructeur
459 vpihour 617 INSERT INTO om_droit VALUES (nextval('om_droit_seq'),'dossier_modifier_instructeur', '2');
460    
461     -- Module 1
462     CREATE TABLE dossier_autorisation_type (
463     dossier_autorisation_type integer,
464     code character varying(20),
465     libelle character varying(100),
466     description text,
467     confidentiel boolean default FALSE
468     );
469    
470     ALTER TABLE ONLY dossier_autorisation_type
471     ADD CONSTRAINT dossier_autorisation_type_pkey PRIMARY KEY (dossier_autorisation_type);
472    
473     CREATE SEQUENCE dossier_autorisation_type_seq
474     INCREMENT 1
475     MINVALUE 1
476     MAXVALUE 9223372036854775807
477     START 1
478     CACHE 1;
479    
480     --
481    
482     CREATE TABLE dossier_autorisation_type_detaille (
483     dossier_autorisation_type_detaille integer,
484     code character varying(20),
485     libelle character varying(100),
486     description text,
487     dossier_autorisation_type integer
488     );
489    
490     ALTER TABLE ONLY dossier_autorisation_type_detaille
491     ADD CONSTRAINT dossier_autorisation_type_detaille_pkey PRIMARY KEY (dossier_autorisation_type_detaille);
492     ALTER TABLE ONLY dossier_autorisation_type_detaille
493     ADD CONSTRAINT dossier_autorisation_type_detaille_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type);
494    
495     CREATE SEQUENCE dossier_autorisation_type_detaille_seq
496     INCREMENT 1
497     MINVALUE 1
498     MAXVALUE 9223372036854775807
499     START 1
500     CACHE 1;
501    
502     --
503    
504     CREATE TABLE dossier_instruction_type (
505     dossier_instruction_type integer,
506     code character varying(20),
507     libelle character varying(100),
508     description text,
509     dossier_autorisation_type_detaille integer,
510     suffixe boolean default FALSE
511     );
512    
513     ALTER TABLE ONLY dossier_instruction_type
514     ADD CONSTRAINT dossier_instruction_type_pkey PRIMARY KEY (dossier_instruction_type);
515     ALTER TABLE ONLY dossier_instruction_type
516     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);
517    
518     CREATE SEQUENCE dossier_instruction_type_seq
519     INCREMENT 1
520     MINVALUE 1
521     MAXVALUE 9223372036854775807
522     START 1
523     CACHE 1;
524    
525     --
526    
527     CREATE TABLE demande_genre (
528     demande_genre integer,
529     code character varying(20),
530     libelle character varying(100),
531     description text
532     );
533    
534     ALTER TABLE ONLY demande_genre
535     ADD CONSTRAINT demande_genre_pkey PRIMARY KEY (demande_genre);
536    
537     CREATE SEQUENCE demande_genre_seq
538     INCREMENT 1
539     MINVALUE 1
540     MAXVALUE 9223372036854775807
541     START 1
542     CACHE 1;
543    
544     --
545    
546     CREATE TABLE groupe (
547     groupe integer,
548     code character varying(20),
549     libelle character varying(100),
550     description text,
551     demande_genre integer
552     );
553    
554     ALTER TABLE ONLY groupe
555     ADD CONSTRAINT groupe_pkey PRIMARY KEY (groupe);
556     ALTER TABLE ONLY groupe
557     ADD CONSTRAINT groupe_demande_genre_fkey FOREIGN KEY (demande_genre) REFERENCES demande_genre(demande_genre);
558    
559     CREATE SEQUENCE groupe_seq
560     INCREMENT 1
561     MINVALUE 1
562     MAXVALUE 9223372036854775807
563     START 1
564     CACHE 1;
565    
566     -- Ajout de clé étrangère à la table dossier_autorisation_type
567     ALTER TABLE dossier_autorisation_type ADD COLUMN groupe integer;
568     ALTER TABLE ONLY dossier_autorisation_type
569     ADD CONSTRAINT dossier_autorisation_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe);
570    
571     --Demande nature
572    
573     CREATE TABLE demande_nature (
574     demande_nature integer,
575     code character varying(20),
576     libelle character varying(100),
577     description text
578     );
579    
580     ALTER TABLE ONLY demande_nature
581     ADD CONSTRAINT demande_nature_pkey PRIMARY KEY (demande_nature);
582    
583     CREATE SEQUENCE demande_nature_seq
584     INCREMENT 1
585     MINVALUE 1
586     MAXVALUE 9223372036854775807
587     START 1
588     CACHE 1;
589    
590     --Demande type
591    
592     CREATE TABLE demande_type (
593     demande_type integer,
594     code character varying(20),
595     libelle character varying(100),
596     description text,
597     demande_nature integer,
598     groupe integer,
599     dossier_instruction_type integer,
600     dossier_autorisation_type_detaille integer,
601     contraintes character varying(20),
602     etats_dossier_autorisation_autorises character varying(100),
603     qualification boolean,
604     evenement integer
605     );
606    
607     ALTER TABLE ONLY demande_type
608     ADD CONSTRAINT demande_type_pkey PRIMARY KEY (demande_type);
609     ALTER TABLE ONLY demande_type
610     ADD CONSTRAINT demande_type_demande_nature_fkey FOREIGN KEY (demande_nature) REFERENCES demande_nature(demande_nature);
611     ALTER TABLE ONLY demande_type
612     ADD CONSTRAINT demande_type_groupe_fkey FOREIGN KEY (groupe) REFERENCES groupe(groupe);
613     ALTER TABLE ONLY demande_type
614     ADD CONSTRAINT demande_type_dossier_instruction_type_fkey FOREIGN KEY (dossier_instruction_type) REFERENCES dossier_instruction_type(dossier_instruction_type);
615     ALTER TABLE ONLY demande_type
616     ADD CONSTRAINT demande_type_dossier_autorisation_type_detaille_fkey FOREIGN KEY (dossier_autorisation_type_detaille) REFERENCES dossier_autorisation_type_detaille(dossier_autorisation_type_detaille);
617     ALTER TABLE ONLY demande_type
618     ADD CONSTRAINT demande_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement);
619    
620     CREATE SEQUENCE demande_type_seq
621     INCREMENT 1
622     MINVALUE 1
623     MAXVALUE 9223372036854775807
624     START 1
625     CACHE 1;
626    
627     --
628    
629     CREATE TABLE lien_evenement_dossier_autorisation_type (
630     lien_evenement_dossier_autorisation_type integer,
631     evenement integer,
632     dossier_autorisation_type integer
633     );
634    
635     ALTER TABLE ONLY lien_evenement_dossier_autorisation_type
636     ADD CONSTRAINT lien_evenement_dossier_autorisation_type_pkey PRIMARY KEY (lien_evenement_dossier_autorisation_type);
637     ALTER TABLE ONLY lien_evenement_dossier_autorisation_type
638     ADD CONSTRAINT lien_evenement_dossier_autorisation_type_evenement_fkey FOREIGN KEY (evenement) REFERENCES evenement(evenement);
639     ALTER TABLE ONLY lien_evenement_dossier_autorisation_type
640     ADD CONSTRAINT lien_evenement_dossier_autorisation_type_dossier_autorisation_type_fkey FOREIGN KEY (dossier_autorisation_type) REFERENCES dossier_autorisation_type(dossier_autorisation_type);
641    
642     CREATE SEQUENCE lien_evenement_dossier_autorisation_type_seq
643     INCREMENT 1
644     MINVALUE 1
645     MAXVALUE 9223372036854775807
646     START 1
647     CACHE 1;
648    
649     --
650    
651     CREATE TABLE autorite_competente (
652     autorite_competente integer,
653     code character varying(20),
654     libelle character varying(100),
655     description text
656     );
657    
658     ALTER TABLE ONLY autorite_competente
659     ADD CONSTRAINT autorite_competente_pkey PRIMARY KEY (autorite_competente);
660    
661     CREATE SEQUENCE autorite_competente_seq
662     INCREMENT 1
663     MINVALUE 1
664     MAXVALUE 9223372036854775807
665     START 1
666     CACHE 1;
667    
668     -- Ajout de clé étrangère à la table dossier_autorisation_type
669     ALTER TABLE dossier ADD COLUMN autorite_competente integer;
670     ALTER TABLE ONLY dossier
671     ADD CONSTRAINT dossier_autorite_competente_fkey FOREIGN KEY (autorite_competente) REFERENCES autorite_competente(autorite_competente);
672    
673     -- Donnees des tables
674     INSERT INTO dossier_autorisation_type(dossier_autorisation_type, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature;
675     INSERT INTO dossier_autorisation_type_detaille(dossier_autorisation_type_detaille, code, libelle) SELECT nextval('dossier_autorisation_type_seq'), nature, libelle FROM nature;
676    
677     INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'URBA', 'Pôle Urbanisme', 'Responsabilité de la DDU');
678     INSERT INTO demande_genre VALUES (nextval('demande_genre_seq'), 'ERP', 'Pôle ERP', 'Responsabilité de la DGUP');
679    
680     INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ADS', 'Autorisation ADS', '',1);
681     INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CTX', 'Contentieux dans le domaine urbanisme', '',1);
682 vpihour 622 INSERT INTO groupe VALUES (nextval('groupe_seq'), 'CU', 'Changement d''usage', '',1);
683     INSERT INTO groupe VALUES (nextval('groupe_seq'), 'RU', 'Renseignement d''urbanisme', '',1);
684 vpihour 617 INSERT INTO groupe VALUES (nextval('groupe_seq'), 'ERP', 'ERP', '',2);

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26