/[openfoncier]/trunk/data/pgsql/v3.1.0-b1.sql
ViewVC logotype

Contents of /trunk/data/pgsql/v3.1.0-b1.sql

Parent Directory Parent Directory | Revision Log Revision Log


Revision 478 - (show annotations)
Tue Oct 9 08:25:41 2012 UTC (12 years, 3 months ago) by nhaye
Original Path: trunk/data/pgsql/v3.1.0-dev.sql
File size: 11323 byte(s)
Suppression des "DEFAULT NEXTVAL()" sur les clés primaire + régénération

1 --
2 -- Contenu de la table om_droit
3 --
4 INSERT INTO om_droit (om_droit, om_profil) VALUES
5
6 ('menu_application', '1'),
7 ('menu_export', '1'),
8 ('menu_parametrage', '1'),
9 ('menu_sig', '1'),
10 ('menu_administration', '1'),
11
12 ('om_sig_map', '4'),
13 ('om_sig_map_comp', '4'),
14 ('om_sig_map_wms', '4'),
15 ('om_sig_wms', '4'),
16
17 ('parcelle_lot', '4'),
18 ('servitude_surfacique', '4'),
19 ('servitude_point', '4'),
20 ('servitude_ligne', '4'),
21
22 ('parametre', '4'),
23 ('num_dossier', '4'),
24 ('regle', '4'),
25
26 ('edition_d', '2'),
27 ('edition', '2'),
28 ('reqmo', '2'),
29 ('export_pc', '2'),
30 ('export_dp', '2'),
31 ('export_sitadel', '2'),
32
33 ('instruction', '2'),
34 ('consultation', '3'),
35 ('terrain', '3'),
36 ('blocnote', '3'),
37 ('destination_shon', '3'),
38 ('modificatif', '3'),
39
40 ('dossier', '3')
41
42 ;
43
44 delete from om_droit where om_droit='om_sig_point';
45
46
47 -- mise a jour OM
48 -- v4.2.0 -> v4.3.0
49
50 ALTER TABLE om_droit ALTER COLUMN om_profil DROP DEFAULT;
51
52 ALTER TABLE om_utilisateur ALTER COLUMN om_utilisateur DROP DEFAULT;
53 ALTER TABLE om_utilisateur ALTER COLUMN nom DROP DEFAULT;
54 ALTER TABLE om_utilisateur ALTER COLUMN email DROP DEFAULT;
55 ALTER TABLE om_utilisateur ALTER COLUMN login DROP DEFAULT;
56 ALTER TABLE om_utilisateur ALTER COLUMN pwd DROP DEFAULT;
57 ALTER TABLE om_utilisateur ALTER COLUMN om_profil DROP DEFAULT;
58 ALTER TABLE om_utilisateur ALTER COLUMN om_type SET DEFAULT 'DB';
59
60 ALTER TABLE om_utilisateur ADD CONSTRAINT om_utilisateur_login_key UNIQUE (login);
61
62 ALTER TABLE om_etat ALTER COLUMN titreattribut SET DEFAULT '';
63 ALTER TABLE om_etat ALTER COLUMN corpsattribut SET DEFAULT '';
64 ALTER TABLE om_etat ALTER COLUMN footerattribut SET DEFAULT '';
65 ALTER TABLE om_etat ALTER COLUMN sousetat SET DEFAULT '';
66 ALTER TABLE om_etat ALTER COLUMN actif TYPE boolean USING CASE WHEN actif='Oui' THEN true ELSE false END;
67 ALTER TABLE om_etat ALTER actif DROP NOT NULL;
68
69
70 ALTER TABLE om_sousetat ALTER COLUMN titreattribut SET DEFAULT '';
71 ALTER TABLE om_sousetat ALTER COLUMN actif TYPE boolean USING CASE WHEN actif='Oui' THEN true ELSE false END;
72 ALTER TABLE om_sousetat ALTER actif DROP NOT NULL;
73 ALTER TABLE om_sousetat ALTER entete_orientation TYPE varchar(100);
74
75 ALTER TABLE om_lettretype ALTER COLUMN titreattribut SET DEFAULT '';
76 ALTER TABLE om_lettretype ALTER COLUMN corpsattribut SET DEFAULT '';
77 ALTER TABLE om_lettretype ALTER COLUMN actif TYPE boolean USING CASE WHEN actif='Oui' THEN true ELSE false END;
78 ALTER TABLE om_lettretype ALTER actif DROP NOT NULL;
79
80 ALTER TABLE avis ALTER libelle DROP DEFAULT;
81 ALTER TABLE bible ALTER libelle DROP DEFAULT;
82 ALTER TABLE bible ALTER contenu SET NOT NULL;
83 ALTER TABLE evenement ALTER libelle DROP DEFAULT;
84 ALTER TABLE etat ALTER libelle DROP DEFAULT;
85 ALTER TABLE transition ALTER etat SET NOT NULL;
86 ALTER TABLE transition ALTER action SET NOT NULL;
87 ALTER TABLE action ALTER libelle DROP DEFAULT;
88 ALTER TABLE parametre ALTER actif DROP NOT NULL;
89 ALTER TABLE rivoli ALTER libelle DROP DEFAULT;
90 ALTER TABLE nature ALTER libelle DROP DEFAULT;
91 ALTER TABLE destination ALTER libelle DROP DEFAULT;
92 ALTER TABLE categorie_demandeur ALTER libelle DROP DEFAULT;
93 ALTER TABLE travaux ALTER libelle DROP DEFAULT;
94 ALTER TABLE service ALTER libelle DROP DEFAULT;
95 ALTER TABLE architecte ALTER nom DROP DEFAULT;
96 ALTER TABLE architecte ALTER note DROP NOT NULL;
97 ALTER TABLE proprietaire ALTER civilite DROP DEFAULT;
98 ALTER TABLE proprietaire ALTER proprietaire SET NOT NULL;
99 ALTER TABLE pos ALTER libelle DROP DEFAULT;
100 ALTER TABLE servitude_surfacique ALTER libelle SET NOT NULL;
101 ALTER TABLE servitude_ligne ALTER libelle SET NOT NULL;
102 ALTER TABLE servitude_point ALTER libelle SET NOT NULL;
103 ALTER TABLE parcelle_lot ALTER lotissement SET NOT NULL;
104 ALTER TABLE dossier ALTER date_depot SET NOT NULL;
105
106 ALTER TABLE instruction ALTER complement DROP NOT NULL;
107 ALTER TABLE instruction ALTER complement2 DROP NOT NULL;
108 ALTER TABLE instruction ALTER evenement SET NOT NULL;
109 ALTER TABLE instruction ALTER datecourrier SET NOT NULL;
110
111 ALTER TABLE consultation ALTER dossier SET NOT NULL;
112 ALTER TABLE consultation ALTER service SET NOT NULL;
113 ALTER TABLE consultation ALTER date_envoi SET NOT NULL;
114
115 ALTER TABLE blocnote ALTER note SET NOT NULL;
116 ALTER TABLE blocnote ALTER categorie DROP DEFAULT;
117
118 -- Ajout des contraintes de clés étrangères sur les tables métiers
119
120 UPDATE evenement SET nature = NULL WHERE nature ='';
121 ALTER TABLE evenement ADD CONSTRAINT evenement_nature_fkey FOREIGN KEY (nature) REFERENCES nature (nature);
122 UPDATE evenement SET action = NULL WHERE action ='';
123 ALTER TABLE evenement ADD CONSTRAINT evenement_action_fkey FOREIGN KEY (action) REFERENCES action (action);
124 UPDATE evenement SET etat = NULL WHERE etat ='';
125 ALTER TABLE evenement ADD CONSTRAINT evenement_etat_fkey FOREIGN KEY (etat) REFERENCES etat (etat);
126 UPDATE evenement SET avis = NULL WHERE avis ='';
127 ALTER TABLE evenement ADD CONSTRAINT evenement_avis_fkey FOREIGN KEY (avis) REFERENCES avis (avis);
128
129 ALTER TABLE bible ADD CONSTRAINT bible_nature_fkey FOREIGN KEY (nature) REFERENCES nature (nature);
130
131 ALTER TABLE travaux ADD CONSTRAINT travaux_nature_fkey FOREIGN KEY (nature) REFERENCES nature (nature);
132
133 ALTER TABLE proprietaire ADD CONSTRAINT proprietaire_pkey PRIMARY KEY (proprietaire);
134 ALTER TABLE proprietaire ADD CONSTRAINT proprietaire_civilite_fkey FOREIGN KEY (civilite) REFERENCES civilite (civilite);
135
136 ALTER TABLE parcelle ALTER rivoli DROP DEFAULT;
137 ALTER TABLE parcelle ALTER rivoli DROP NOT NULL;
138 ALTER TABLE parcelle ADD CONSTRAINT parcelle_rivoli_fkey FOREIGN KEY (rivoli) REFERENCES rivoli (rivoli);
139 ALTER TABLE parcelle ADD CONSTRAINT parcelle_proprietaire_fkey FOREIGN KEY (proprietaire) REFERENCES proprietaire (proprietaire);
140 ALTER TABLE parcelle ADD CONSTRAINT parcelle_pos_fkey FOREIGN KEY (pos) REFERENCES pos (pos);
141
142 ALTER TABLE ONLY om_widget
143 ADD CONSTRAINT om_widget_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil);
144
145 ALTER TABLE dossier ALTER rivoli DROP DEFAULT;
146 ALTER TABLE dossier ALTER rivoli DROP NOT NULL;
147 ALTER TABLE dossier ALTER pos DROP DEFAULT;
148 ALTER TABLE dossier ALTER pos DROP NOT NULL;
149 ALTER TABLE dossier ALTER parcelle DROP DEFAULT;
150 ALTER TABLE dossier ALTER parcelle DROP NOT NULL;
151 ALTER TABLE dossier ADD CONSTRAINT dossier_rivoli_fkey FOREIGN KEY (rivoli) REFERENCES rivoli (rivoli);
152 ALTER TABLE dossier ADD CONSTRAINT dossier_pos_fkey FOREIGN KEY (pos) REFERENCES pos (pos);
153 ALTER TABLE dossier ADD CONSTRAINT dossier_parcelle_lot_fkey FOREIGN KEY (parcelle_lot) REFERENCES parcelle_lot (parcelle_lot);
154 ALTER TABLE dossier ADD CONSTRAINT dossier_parcelle_fkey FOREIGN KEY (parcelle) REFERENCES parcelle (parcelle);
155
156 ALTER TABLE instruction ADD CONSTRAINT instruction_action_fkey FOREIGN KEY (action) REFERENCES action (action);
157 ALTER TABLE instruction ADD CONSTRAINT instruction_etat_fkey FOREIGN KEY (etat) REFERENCES etat (etat);
158 ALTER TABLE instruction ADD CONSTRAINT instruction_avis_fkey FOREIGN KEY (avis) REFERENCES avis (avis);
159
160 ALTER TABLE terrain ADD CONSTRAINT terrain_parcelle_fkey FOREIGN KEY (parcelle) REFERENCES parcelle (parcelle);
161
162 ALTER TABLE destination_shon ALTER destination SET NOT NULL;
163
164 ALTER TABLE regle ALTER message DROP DEFAULT;
165 ALTER TABLE regle ALTER valeur DROP DEFAULT;
166 ALTER TABLE regle ALTER champ DROP DEFAULT;
167 ALTER TABLE regle ALTER operateur DROP DEFAULT;
168 ALTER TABLE regle ALTER sens DROP DEFAULT;
169 ALTER TABLE regle ALTER ordre DROP DEFAULT;
170
171 ALTER TABLE om_profil ALTER COLUMN om_profil DROP DEFAULT;
172
173 ALTER TABLE om_widget ALTER COLUMN om_profil SET NOT NULL;
174
175 ALTER TABLE dossier ALTER COLUMN nature SET NOT NULL;
176
177
178
179
180 ---
181 --- Gestion des profils non hiérarchiques / Mise à jour OBLIGATOIRE om 4.3.0
182 ---
183
184 ---
185 ALTER TABLE om_droit DROP CONSTRAINT om_droit_pkey;
186 ALTER TABLE om_droit DROP CONSTRAINT om_droit_om_profil_fkey;
187 ALTER TABLE om_utilisateur DROP CONSTRAINT om_utilisateur_om_profil_fkey;
188 ALTER TABLE om_widget DROP CONSTRAINT om_widget_om_profil_fkey;
189 ALTER TABLE om_profil DROP CONSTRAINT om_profil_pkey;
190
191 ALTER TABLE om_droit RENAME COLUMN om_droit TO om_droit_old;
192 ALTER TABLE om_droit RENAME COLUMN om_profil TO om_profil_old;
193
194 CREATE SEQUENCE om_droit_seq
195 START WITH 1
196 INCREMENT BY 1
197 NO MAXVALUE
198 NO MINVALUE
199 CACHE 1;
200
201 ALTER TABLE om_droit ADD COLUMN om_droit integer NOT NULL DEFAULT nextval('om_droit_seq'::regclass);
202 ALTER TABLE om_droit ADD COLUMN libelle character varying(100);
203 ALTER TABLE om_droit ADD COLUMN om_profil integer;
204
205 UPDATE om_droit SET libelle=om_droit_old;
206 UPDATE om_droit SET om_profil=om_profil_old::integer;
207 ---
208 ALTER TABLE om_profil RENAME COLUMN om_profil TO om_profil_old;
209 ALTER TABLE om_profil RENAME COLUMN libelle TO libelle_old;
210
211 CREATE SEQUENCE om_profil_seq
212 START WITH 1
213 INCREMENT BY 1
214 NO MAXVALUE
215 NO MINVALUE
216 CACHE 1;
217
218 ALTER TABLE om_profil ADD COLUMN om_profil integer NOT NULL DEFAULT nextval('om_profil_seq'::regclass);
219 ALTER TABLE om_profil ADD COLUMN libelle character varying(100);
220 ALTER TABLE om_profil ADD COLUMN hierarchie integer NOT NULL DEFAULT 0 ;
221
222 UPDATE om_profil SET libelle=libelle_old;
223 UPDATE om_profil SET hierarchie=om_profil_old::integer;
224 UPDATE om_droit SET om_profil=(select om_profil.om_profil from om_profil where hierarchie=om_droit.om_profil_old::integer);
225 ---
226 ALTER TABLE om_utilisateur RENAME COLUMN om_profil TO om_profil_old;
227 ALTER TABLE om_utilisateur ADD COLUMN om_profil integer;
228
229 UPDATE om_utilisateur SET om_profil=(select om_profil.om_profil from om_profil where hierarchie=om_utilisateur.om_profil_old::integer);
230 ---
231 ALTER TABLE om_widget RENAME COLUMN om_profil TO om_profil_old;
232 ALTER TABLE om_widget ADD COLUMN om_profil integer;
233
234 UPDATE om_widget SET om_profil=(select om_profil.om_profil from om_profil where hierarchie=om_widget.om_profil_old::integer);
235 ---
236 ALTER TABLE om_droit ALTER COLUMN libelle SET NOT NULL;
237 ALTER TABLE om_droit ALTER COLUMN om_profil SET NOT NULL;
238 ALTER TABLE om_profil ALTER COLUMN libelle SET NOT NULL;
239 ALTER TABLE om_utilisateur ALTER COLUMN om_profil SET NOT NULL;
240 ALTER TABLE om_widget ALTER COLUMN om_profil SET NOT NULL;
241
242
243
244
245 ALTER TABLE om_droit DROP COLUMN om_droit_old;
246 ALTER TABLE om_droit DROP COLUMN om_profil_old;
247 ALTER TABLE om_profil DROP COLUMN libelle_old;
248 ALTER TABLE om_profil DROP COLUMN om_profil_old;
249 ALTER TABLE om_utilisateur DROP COLUMN om_profil_old;
250 ALTER TABLE om_widget DROP COLUMN om_profil_old;
251
252 ---
253
254 ALTER TABLE ONLY om_droit
255 ADD CONSTRAINT om_droit_pkey PRIMARY KEY (om_droit);
256
257 ALTER TABLE ONLY om_profil
258 ADD CONSTRAINT om_profil_pkey PRIMARY KEY (om_profil);
259
260 ALTER TABLE ONLY om_utilisateur
261 ADD CONSTRAINT om_utilisateur_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil);
262
263 ALTER TABLE ONLY om_droit
264 ADD CONSTRAINT om_droit_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil);
265
266 ALTER TABLE ONLY om_widget
267 ADD CONSTRAINT om_widget_om_profil_fkey FOREIGN KEY (om_profil) REFERENCES om_profil(om_profil);
268
269 ALTER TABLE ONLY om_droit
270 ADD CONSTRAINT om_droit_libelle_om_profil_key UNIQUE (libelle, om_profil);
271
272 ALTER SEQUENCE om_profil_seq OWNED BY om_profil.om_profil;
273 ALTER SEQUENCE om_droit_seq OWNED BY om_droit.om_droit;
274
275 ALTER TABLE om_droit ALTER COLUMN om_droit DROP DEFAULT;
276 ALTER TABLE om_profil ALTER COLUMN om_profil DROP DEFAULT;
277 ALTER SEQUENCE om_utilisateur_seq OWNED BY om_utilisateur.om_utilisateur;
278 ALTER SEQUENCE om_parametre_seq OWNED BY om_parametre.om_parametre;
279
280 ---

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26