DB Migration Process » History » Version 22
Amber Herold, 02/09/2010 02:00 PM
1 | 1 | Amber Herold | h1. DB Migration Process |
---|---|---|---|
2 | |||
3 | 3 | Amber Herold | The tables that will be affected are in the dbemdata database and the project database. |
4 | Migrate the user data from project to dbemdata because dbemdata is already in Sinedon format. |
||
5 | 4 | Amber Herold | |
6 | 5 | Amber Herold | |
7 | 1 | Amber Herold | +dbemdata+ |
8 | |||
9 | * GroupData |
||
10 | 10 | Amber Herold | * UserData (81 rows) |
11 | 1 | Amber Herold | |
12 | +project+ |
||
13 | |||
14 | 10 | Amber Herold | * users (233 rows) |
15 | * login (187 rows) |
||
16 | * pis (145 rows) |
||
17 | 1 | Amber Herold | * userdetails |
18 | * projectowner |
||
19 | 5 | Amber Herold | |
20 | 6 | Amber Herold | Future: |
21 | 5 | Amber Herold | Eventually, we would like to have 3 databases, appion, leginon and project. The user related tables in dbemdata would be moved to project. |
22 | All the tables in project still need to be converted to Sinedon format. |
||
23 | 2 | Amber Herold | |
24 | h2. 1 Add new columns to UserData |
||
25 | |||
26 | Add: |
||
27 | |||
28 | * username |
||
29 | * fullname |
||
30 | * firstname |
||
31 | * lastname |
||
32 | * password |
||
33 | |||
34 | |||
35 | Leave the existing columns as is. Use of "name" and "full name" (with a space) will be phased out. |
||
36 | 1 | Amber Herold | |
37 | 3 | Amber Herold | h2. 2 Copy data to the UserData table |
38 | |||
39 | From users, copy username, firstname, lastname to UserData. |
||
40 | 12 | Amber Herold | |
41 | h3. Update existing dbemdata.UserData entries with information from project.users when the names match. |
||
42 | |||
43 | 13 | Amber Herold | <pre> |
44 | UPDATE UserData, project.users, project.login |
||
45 | 12 | Amber Herold | SET UserData.username=project.users.username, |
46 | UserData.firstname=project.users.firstname, |
||
47 | UserData.lastname=project.users.lastname, |
||
48 | UserData.email=project.users.email |
||
49 | WHERE UserData.`full name` like concat(project.users.firstname, ' ',project.users.lastname) |
||
50 | 1 | Amber Herold | and project.login.userId = project.users.userId |
51 | and project.users.userId not in(63,211) |
||
52 | 13 | Amber Herold | and UserData.DEF_id != 54 |
53 | </pre> |
||
54 | 12 | Amber Herold | |
55 | h3. Some names did not match exactly. Update these seperatly. |
||
56 | |||
57 | |||
58 | <pre> |
||
59 | //Palida? |
||
60 | UPDATE UserData, projectdata.users |
||
61 | SET UserData.username=projectdata.users.username, |
||
62 | UserData.firstname=projectdata.users.firstname, |
||
63 | UserData.lastname=projectdata.users.lastname, |
||
64 | UserData.email=projectdata.users.email |
||
65 | WHERE projectdata.users.userId = 42 |
||
66 | AND UserData.DEF_id = 25 |
||
67 | |||
68 | //Gabe? |
||
69 | UPDATE UserData, projectdata.users |
||
70 | SET UserData.username=projectdata.users.username, |
||
71 | UserData.firstname=projectdata.users.firstname, |
||
72 | UserData.lastname=projectdata.users.lastname, |
||
73 | UserData.email=projectdata.users.email |
||
74 | WHERE projectdata.users.userId = 65 |
||
75 | AND UserData.DEF_id = 29 |
||
76 | |||
77 | //Edward Bridgnole |
||
78 | UPDATE UserData, projectdata.users |
||
79 | SET UserData.username=projectdata.users.username, |
||
80 | UserData.firstname=projectdata.users.firstname, |
||
81 | UserData.lastname=projectdata.users.lastname, |
||
82 | UserData.email=projectdata.users.email |
||
83 | WHERE projectdata.users.userId = 78 |
||
84 | AND UserData.DEF_id = 41 |
||
85 | |||
86 | //Pickwei |
||
87 | UPDATE UserData, projectdata.users |
||
88 | SET UserData.username=projectdata.users.username, |
||
89 | UserData.firstname=projectdata.users.firstname, |
||
90 | UserData.lastname=projectdata.users.lastname, |
||
91 | UserData.email=projectdata.users.email |
||
92 | WHERE projectdata.users.userId = 122 |
||
93 | AND UserData.DEF_id = 57 |
||
94 | |||
95 | //Mark Daniels |
||
96 | UPDATE UserData, projectdata.users |
||
97 | SET UserData.username=projectdata.users.username, |
||
98 | UserData.firstname=projectdata.users.firstname, |
||
99 | UserData.lastname=projectdata.users.lastname, |
||
100 | UserData.email=projectdata.users.email |
||
101 | WHERE projectdata.users.userId = 199 |
||
102 | AND UserData.DEF_id = 65 |
||
103 | |||
104 | //Chris Arthur |
||
105 | UPDATE UserData, projectdata.users |
||
106 | SET UserData.username=projectdata.users.username, |
||
107 | UserData.firstname=projectdata.users.firstname, |
||
108 | UserData.lastname=projectdata.users.lastname, |
||
109 | UserData.email=projectdata.users.email |
||
110 | WHERE projectdata.users.userId = 35 |
||
111 | AND UserData.DEF_id = 67 |
||
112 | |||
113 | //Fei Sun |
||
114 | UPDATE UserData, projectdata.users |
||
115 | SET UserData.username=projectdata.users.username, |
||
116 | UserData.firstname=projectdata.users.firstname, |
||
117 | UserData.lastname=projectdata.users.lastname, |
||
118 | UserData.email=projectdata.users.email |
||
119 | WHERE projectdata.users.userId = 233 |
||
120 | AND UserData.DEF_id = 76 |
||
121 | |||
122 | //Chi-yu Fu |
||
123 | UPDATE UserData, projectdata.users |
||
124 | SET UserData.username=projectdata.users.username, |
||
125 | UserData.firstname=projectdata.users.firstname, |
||
126 | UserData.lastname=projectdata.users.lastname, |
||
127 | UserData.email=projectdata.users.email |
||
128 | WHERE projectdata.users.userId = 245 |
||
129 | AND UserData.DEF_id = 78 |
||
130 | |||
131 | //Otomo Takanori uId=79 puId=252 |
||
132 | UPDATE UserData, projectdata.users |
||
133 | SET UserData.username=projectdata.users.username, |
||
134 | UserData.firstname=projectdata.users.firstname, |
||
135 | UserData.lastname=projectdata.users.lastname, |
||
136 | UserData.email=projectdata.users.email |
||
137 | WHERE projectdata.users.userId = 252 |
||
138 | AND UserData.DEF_id = 79 |
||
139 | </pre> |
||
140 | |||
141 | h3. Insert the rest of the project.users entries into the dbemdata.UserData table. |
||
142 | |||
143 | This inserts users that have a corresponding project.login entry and have not already been merged into existing dbemdata.UserData entries. |
||
144 | NRAMM usernames with no login entry are not transferred. |
||
145 | |||
146 | <pre> |
||
147 | INSERT INTO dbemdata.UserData (username, firstname, lastname, email) |
||
148 | SELECT projectdata.users.username,projectdata.users.firstname, projectdata.users.lastname,projectdata.users.email |
||
149 | FROM projectdata.users |
||
150 | WHERE projectdata.users.userId IN (SELECT projectdata.login.userId FROM projectdata.login) |
||
151 | AND (projectdata.users.userId NOT IN |
||
152 | ( |
||
153 | SELECT projectdata.users.userId userId |
||
154 | FROM dbemdata.UserData, projectdata.users, projectdata.login |
||
155 | WHERE dbemdata.UserData.`full name` LIKE concat( projectdata.users.firstname, ' ', projectdata.users.lastname ) |
||
156 | AND projectdata.login.userId = projectdata.users.userId |
||
157 | ) |
||
158 | AND projectdata.users.userId NOT IN ( 42, 65, 78, 122, 199, 35, 233, 245, 252, 63, 211 )) |
||
159 | </pre> |
||
160 | |||
161 | |||
162 | h3. From project.login, copy user password to dbemdata.UserData. |
||
163 | |||
164 | |||
165 | <pre> |
||
166 | UPDATE dbemdata.UserData, projectdata.login |
||
167 | SET dbemdata.UserData.password=projectdata.login.password |
||
168 | WHERE dbemdata.UserData.username = projectdata.login.username |
||
169 | </pre> |
||
170 | 3 | Amber Herold | |
171 | 22 | Amber Herold | h2. 4 Modify userdetails table |
172 | 1 | Amber Herold | |
173 | 22 | Amber Herold | Remove the email column from the userdetails table. |
174 | From users, copy all needed fields. |
||
175 | 1 | Amber Herold | |
176 | 22 | Amber Herold | h3. Copy users from dbemdata.UserData to the project.userdetails table. inserts 188 rows |
177 | |||
178 | <pre> |
||
179 | INSERT INTO projectdata.userdetails |
||
180 | (`REF|leginondata|UserData|user`, |
||
181 | title, |
||
182 | institution, |
||
183 | dept, |
||
184 | address, |
||
185 | city, |
||
186 | statecountry, |
||
187 | zip, |
||
188 | phone, |
||
189 | fax, |
||
190 | url) |
||
191 | SELECT dbemdata.UserData.DEF_id, projectdata.users.title, projectdata.users.institution, |
||
192 | projectdata.users.dept, projectdata.users.address, projectdata.users.city, |
||
193 | projectdata.users.statecountry, projectdata.users.zip, projectdata.users.phone, |
||
194 | projectdata.users.fax, projectdata.users.url |
||
195 | FROM dbemdata.UserData, projectdata.users |
||
196 | WHERE dbemdata.UserData.username = projectdata.users.username |
||
197 | AND projectdata.users.userId NOT IN ( 216, 224, 107, 204, 219, 241, 261 ) |
||
198 | </pre> |
||
199 | |||
200 | ignore: |
||
201 | project.users.userId username |
||
202 | 216 nramm_hetzer (dup w/less data) |
||
203 | 224 nramm_hjing |
||
204 | 107 nramm_jlanman |
||
205 | 204 nramm_rkhayat |
||
206 | 219 nramm_rkhayat |
||
207 | 241 nramm_vinzenz.unger |
||
208 | 261 nramm_vinzenz.unger |
||
209 | |||
210 | 3 | Amber Herold | h2. 3 Create projectowner table |
211 | |||
212 | Move the data from pis table to a new projectowner table in the project database. This table will refer to users in the UserData table. |
||
213 | We will phase out use of the pis table. |
||
214 | |||
215 | 20 | Amber Herold | *Insert users that are project owners and do not have login info and do not have a dbem user name.* |
216 | Set the passwords to the username. |
||
217 | |||
218 | Add the following project owners to dbemdata.UserData: |
||
219 | 18 | Amber Herold | nramm_mbevans |
220 | nramm_erica |
||
221 | nramm_erwright |
||
222 | nramm_mgfinn |
||
223 | nramm_pucadyil |
||
224 | nramm_abaudoux |
||
225 | nramm_kuzman |
||
226 | nramm_my3r |
||
227 | nramm_liguo.wang |
||
228 | nramm_bbartholomew |
||
229 | nramm_cciferri |
||
230 | nramm_galushin |
||
231 | nramm_nachury |
||
232 | nramm_mfisher1 |
||
233 | nramm_nicoles |
||
234 | nramm_gokhan_tolun |
||
235 | nramm_rkirchdo |
||
236 | 19 | Amber Herold | |
237 | 1 | Amber Herold | |
238 | |||
239 | <pre> |
||
240 | INSERT INTO dbemdata.UserData (username, firstname, lastname, email, password) |
||
241 | 20 | Amber Herold | SELECT projectdata.users.username,projectdata.users.firstname, projectdata.users.lastname, |
242 | projectdata.users.email, projectdata.users.username |
||
243 | 1 | Amber Herold | FROM projectdata.users |
244 | 20 | Amber Herold | WHERE projectdata.users.username IN ("nramm_mbevans", "nramm_erica", "nramm_erwright", "nramm_mgfinn", |
245 | "nramm_pucadyil", "nramm_abaudoux", "nramm_kuzman", "nramm_my3r", "nramm_liguo.wang", "nramm_bbartholomew", |
||
246 | "nramm_cciferri", "nramm_galushin", "nramm_nachury", "nramm_mfisher1", "nramm_nicoles", "nramm_gokhan_tolun", |
||
247 | "nramm_rkirchdo") |
||
248 | 1 | Amber Herold | </pre> |
249 | |||
250 | 20 | Amber Herold | *Add their details into the userdetails table* |
251 | 1 | Amber Herold | |
252 | <pre> |
||
253 | 20 | Amber Herold | INSERT INTO projectdata.userdetails (`REF|leginondata|UserData|user`, title, institution, |
254 | dept, address, city, statecountry, zip, phone, fax, url) |
||
255 | SELECT dbemdata.UserData.DEF_id, projectdata.users.title, projectdata.users.institution, |
||
256 | projectdata.users.dept, projectdata.users.address, projectdata.users.city, projectdata.users.statecountry, |
||
257 | projectdata.users.zip, projectdata.users.phone, projectdata.users.fax, projectdata.users.url |
||
258 | 1 | Amber Herold | FROM dbemdata.UserData, projectdata.users |
259 | WHERE dbemdata.UserData.username = projectdata.users.username |
||
260 | 20 | Amber Herold | AND projectdata.users.username IN ( "nramm_mbevans", "nramm_erica", "nramm_erwright", |
261 | "nramm_mgfinn", "nramm_pucadyil", "nramm_abaudoux", "nramm_kuzman", "nramm_my3r", "nramm_liguo.wang", |
||
262 | "nramm_bbartholomew", "nramm_cciferri", "nramm_galushin", "nramm_nachury", "nramm_mfisher1", "nramm_nicoles", |
||
263 | "nramm_gokhan_tolun", "nramm_rkirchdo") |
||
264 | 1 | Amber Herold | </pre> |
265 | 19 | Amber Herold | |
266 | 20 | Amber Herold | *Update the pis table with the correct usernames.* |
267 | The correct usernames are the ones that the users actually use to login to the system. |
||
268 | They have been found by manual inspection. |
||
269 | 19 | Amber Herold | |
270 | <pre> |
||
271 | UPDATE projectdata.pis |
||
272 | SET projectdata.pis.username="chappie" |
||
273 | WHERE projectdata.pis.username="nramm_chappie" |
||
274 | |||
275 | UPDATE projectdata.pis |
||
276 | SET projectdata.pis.username="carthur" |
||
277 | WHERE projectdata.pis.username="nramm_Christopher.Arthur" |
||
278 | |||
279 | UPDATE projectdata.pis |
||
280 | SET projectdata.pis.username="cpotter" |
||
281 | WHERE projectdata.pis.username="nramm_cpotter" |
||
282 | |||
283 | UPDATE projectdata.pis |
||
284 | SET projectdata.pis.username="craigyk" |
||
285 | WHERE projectdata.pis.username="nramm_craigyk" |
||
286 | |||
287 | UPDATE projectdata.pis |
||
288 | SET projectdata.pis.username="dfellman" |
||
289 | WHERE projectdata.pis.username="nramm_dfellman" |
||
290 | |||
291 | UPDATE projectdata.pis |
||
292 | SET projectdata.pis.username="dlyumkis" |
||
293 | WHERE projectdata.pis.username="nramm_dlyumkis" |
||
294 | |||
295 | UPDATE projectdata.pis |
||
296 | SET projectdata.pis.username="southworth" |
||
297 | WHERE projectdata.pis.username="nramm_dsouthwo" |
||
298 | |||
299 | UPDATE projectdata.pis |
||
300 | SET projectdata.pis.username="fapalida" |
||
301 | WHERE projectdata.pis.username="nramm_fapalida" |
||
302 | |||
303 | UPDATE projectdata.pis |
||
304 | SET projectdata.pis.username="feisun" |
||
305 | WHERE projectdata.pis.username="nramm_feisun" |
||
306 | |||
307 | UPDATE projectdata.pis |
||
308 | SET projectdata.pis.username="glander" |
||
309 | WHERE projectdata.pis.username="nramm_glander" |
||
310 | |||
311 | UPDATE projectdata.pis |
||
312 | SET projectdata.pis.username="haoyan" |
||
313 | WHERE projectdata.pis.username="nramm_hao.yan" |
||
314 | |||
315 | UPDATE projectdata.pis |
||
316 | SET projectdata.pis.username="jaeger" |
||
317 | WHERE projectdata.pis.username="nramm_jaeger" |
||
318 | |||
319 | UPDATE projectdata.pis |
||
320 | SET projectdata.pis.username="koehn" |
||
321 | WHERE projectdata.pis.username="nramm_koehn" |
||
322 | |||
323 | UPDATE projectdata.pis |
||
324 | SET projectdata.pis.username="mmatho" |
||
325 | WHERE projectdata.pis.username="nramm_mmatho" |
||
326 | |||
327 | UPDATE projectdata.pis |
||
328 | SET projectdata.pis.username="moeller" |
||
329 | WHERE projectdata.pis.username="nramm_moeller" |
||
330 | |||
331 | UPDATE projectdata.pis |
||
332 | SET projectdata.pis.username="muldera" |
||
333 | WHERE projectdata.pis.username="nramm_mulderam" |
||
334 | |||
335 | UPDATE projectdata.pis |
||
336 | SET projectdata.pis.username="paventer" |
||
337 | WHERE projectdata.pis.username="nramm_paventer" |
||
338 | |||
339 | UPDATE projectdata.pis |
||
340 | SET projectdata.pis.username="rharshey" |
||
341 | WHERE projectdata.pis.username="nramm_rasika" |
||
342 | |||
343 | UPDATE projectdata.pis |
||
344 | SET projectdata.pis.username="nramm_langlois" |
||
345 | WHERE projectdata.pis.username="nramm_rl2528" |
||
346 | |||
347 | UPDATE projectdata.pis |
||
348 | SET projectdata.pis.username="rmglaeser" |
||
349 | WHERE projectdata.pis.username="nramm_rmglaeser" |
||
350 | |||
351 | UPDATE projectdata.pis |
||
352 | SET projectdata.pis.username="rtaurog" |
||
353 | WHERE projectdata.pis.username="nramm_rtaurog" |
||
354 | |||
355 | UPDATE projectdata.pis |
||
356 | SET projectdata.pis.username="sstagg" |
||
357 | 1 | Amber Herold | WHERE projectdata.pis.username="nramm_sstagg" |
358 | 3 | Amber Herold | |
359 | 1 | Amber Herold | UPDATE projectdata.pis |
360 | 11 | Amber Herold | SET projectdata.pis.username="tgonen" |
361 | 14 | Amber Herold | WHERE projectdata.pis.username="nramm_tgonen" |
362 | |||
363 | UPDATE projectdata.pis |
||
364 | SET projectdata.pis.username="vossman" |
||
365 | 15 | Amber Herold | WHERE projectdata.pis.username="nramm_vossman" |
366 | |||
367 | UPDATE projectdata.pis |
||
368 | SET projectdata.pis.username="ychaban" |
||
369 | WHERE projectdata.pis.username="nramm_ychaban" |
||
370 | </pre> |
||
371 | |||
372 | *Add project co-owners (the people who actually access the project).* |
||
373 | Many of the project owners do not actually access the data. Add the users who actually work with the project. |
||
374 | |||
375 | <pre> |
||
376 | INSERT INTO projectdata.pis (projectId, username) |
||
377 | VALUES (200,"nramm_fazam"), (230,"glander"), (190,"jlee"), |
||
378 | (231,"glander"), (203,"Ranjan"), (181,"kubalek"), (84,"strable"), |
||
379 | (222,"nramm_barbie"), (199,"joelq") |
||
380 | </pre> |
||
381 | 14 | Amber Herold | |
382 | *Insert rows into projectowners.* |
||
383 | All project owners now have usernames in dbemdata.UserData and all projects have an active owner in project.pis. |
||
384 | |||
385 | <pre> |
||
386 | INSERT INTO projectdata.projectowners (`REF|projects|project`, `REF|leginondata|UserData|user`) |
||
387 | SELECT projectdata.pis.projectId, dbemdata.UserData.DEF_id |
||
388 | FROM dbemdata.UserData, projectdata.pis |
||
389 | 1 | Amber Herold | WHERE dbemdata.UserData.username = projectdata.pis.username |
390 | </pre> |
||
391 | 14 | Amber Herold | |
392 | 22 | Amber Herold | h2. Set groups and privileges |
393 | 14 | Amber Herold | |
394 | 22 | Amber Herold | h3. Set all null groups to 4 (users) |
395 | 14 | Amber Herold | |
396 | 22 | Amber Herold | h3. set all group privileges that are null to 3 |
397 | 2 | Amber Herold | |
398 | 1 | Amber Herold |