Project

General

Profile

DB Migration Process » History » Version 21

Amber Herold, 02/09/2010 01:57 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
* email
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 16 Amber Herold
h3. Set all null groups to 4 (users)
172
173 17 Amber Herold
h3. set all group privelges that are null to 3
174
175 3 Amber Herold
h2. 3 Create projectowner table
176
177
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. 
178
We will phase out use of the pis table. 
179
180 20 Amber Herold
*Insert users that are project owners and do not have login info and do not have a dbem user name.*
181
Set the passwords to the username.
182
183
Add the following project owners to dbemdata.UserData:
184 18 Amber Herold
nramm_mbevans
185
nramm_erica
186
nramm_erwright
187
nramm_mgfinn
188
nramm_pucadyil
189
nramm_abaudoux
190
nramm_kuzman
191
nramm_my3r
192
nramm_liguo.wang
193
nramm_bbartholomew
194
nramm_cciferri
195
nramm_galushin
196
nramm_nachury
197
nramm_mfisher1
198
nramm_nicoles
199
nramm_gokhan_tolun
200
nramm_rkirchdo
201 19 Amber Herold
202 1 Amber Herold
203
204
<pre>
205
INSERT INTO dbemdata.UserData (username, firstname, lastname, email, password)
206 20 Amber Herold
SELECT projectdata.users.username,projectdata.users.firstname, projectdata.users.lastname, 
207
projectdata.users.email, projectdata.users.username
208 1 Amber Herold
FROM projectdata.users
209 20 Amber Herold
WHERE projectdata.users.username IN ("nramm_mbevans", "nramm_erica", "nramm_erwright", "nramm_mgfinn", 
210
"nramm_pucadyil", "nramm_abaudoux", "nramm_kuzman", "nramm_my3r", "nramm_liguo.wang", "nramm_bbartholomew", 
211
"nramm_cciferri", "nramm_galushin", "nramm_nachury", "nramm_mfisher1", "nramm_nicoles", "nramm_gokhan_tolun", 
212
"nramm_rkirchdo")
213 1 Amber Herold
</pre>
214
215 20 Amber Herold
*Add their details into the userdetails table*
216 1 Amber Herold
217
<pre>
218 20 Amber Herold
INSERT INTO projectdata.userdetails (`REF|leginondata|UserData|user`, title, institution, 
219
dept, address, city, statecountry, zip, phone, fax, url)
220
SELECT dbemdata.UserData.DEF_id, projectdata.users.title, projectdata.users.institution, 
221
projectdata.users.dept, projectdata.users.address, projectdata.users.city, projectdata.users.statecountry, 
222
projectdata.users.zip, projectdata.users.phone, projectdata.users.fax, projectdata.users.url
223 1 Amber Herold
FROM dbemdata.UserData, projectdata.users
224
WHERE dbemdata.UserData.username = projectdata.users.username
225 20 Amber Herold
AND projectdata.users.username IN ( "nramm_mbevans", "nramm_erica", "nramm_erwright", 
226
"nramm_mgfinn", "nramm_pucadyil", "nramm_abaudoux", "nramm_kuzman", "nramm_my3r", "nramm_liguo.wang", 
227
"nramm_bbartholomew", "nramm_cciferri", "nramm_galushin", "nramm_nachury", "nramm_mfisher1", "nramm_nicoles", 
228
"nramm_gokhan_tolun", "nramm_rkirchdo")
229 1 Amber Herold
</pre>
230 19 Amber Herold
231 20 Amber Herold
*Update the pis table with the correct usernames.* 
232
The correct usernames are the ones that the users actually use to login to the system.
233
They have been found by manual inspection.
234 19 Amber Herold
235
<pre>
236
UPDATE projectdata.pis
237
SET projectdata.pis.username="chappie"
238
WHERE projectdata.pis.username="nramm_chappie"
239
240
UPDATE projectdata.pis
241
SET projectdata.pis.username="carthur"
242
WHERE projectdata.pis.username="nramm_Christopher.Arthur"
243
244
UPDATE projectdata.pis
245
SET projectdata.pis.username="cpotter"
246
WHERE projectdata.pis.username="nramm_cpotter"
247
248
UPDATE projectdata.pis
249
SET projectdata.pis.username="craigyk"
250
WHERE projectdata.pis.username="nramm_craigyk"
251
252
UPDATE projectdata.pis
253
SET projectdata.pis.username="dfellman"
254
WHERE projectdata.pis.username="nramm_dfellman"
255
256
UPDATE projectdata.pis
257
SET projectdata.pis.username="dlyumkis"
258
WHERE projectdata.pis.username="nramm_dlyumkis"
259
260
UPDATE projectdata.pis
261
SET projectdata.pis.username="southworth"
262
WHERE projectdata.pis.username="nramm_dsouthwo"
263
264
UPDATE projectdata.pis
265
SET projectdata.pis.username="fapalida"
266
WHERE projectdata.pis.username="nramm_fapalida"
267
268
UPDATE projectdata.pis
269
SET projectdata.pis.username="feisun"
270
WHERE projectdata.pis.username="nramm_feisun"
271
272
UPDATE projectdata.pis
273
SET projectdata.pis.username="glander"
274
WHERE projectdata.pis.username="nramm_glander"
275
276
UPDATE projectdata.pis
277
SET projectdata.pis.username="haoyan"
278
WHERE projectdata.pis.username="nramm_hao.yan"
279
280
UPDATE projectdata.pis
281
SET projectdata.pis.username="jaeger"
282
WHERE projectdata.pis.username="nramm_jaeger"
283
284
UPDATE projectdata.pis
285
SET projectdata.pis.username="koehn"
286
WHERE projectdata.pis.username="nramm_koehn"
287
288
UPDATE projectdata.pis
289
SET projectdata.pis.username="mmatho"
290
WHERE projectdata.pis.username="nramm_mmatho"
291
292
UPDATE projectdata.pis
293
SET projectdata.pis.username="moeller"
294
WHERE projectdata.pis.username="nramm_moeller"
295
296
UPDATE projectdata.pis
297
SET projectdata.pis.username="muldera"
298
WHERE projectdata.pis.username="nramm_mulderam"
299
300
UPDATE projectdata.pis
301
SET projectdata.pis.username="paventer"
302
WHERE projectdata.pis.username="nramm_paventer"
303
304
UPDATE projectdata.pis
305
SET projectdata.pis.username="rharshey"
306
WHERE projectdata.pis.username="nramm_rasika"
307
308
UPDATE projectdata.pis
309
SET projectdata.pis.username="nramm_langlois"
310
WHERE projectdata.pis.username="nramm_rl2528"
311
312
UPDATE projectdata.pis
313
SET projectdata.pis.username="rmglaeser"
314
WHERE projectdata.pis.username="nramm_rmglaeser"
315
316
UPDATE projectdata.pis
317
SET projectdata.pis.username="rtaurog"
318
WHERE projectdata.pis.username="nramm_rtaurog"
319
320
UPDATE projectdata.pis
321
SET projectdata.pis.username="sstagg"
322
WHERE projectdata.pis.username="nramm_sstagg"
323
324
UPDATE projectdata.pis
325 1 Amber Herold
SET projectdata.pis.username="tgonen"
326
WHERE projectdata.pis.username="nramm_tgonen"
327 19 Amber Herold
328
UPDATE projectdata.pis
329
SET projectdata.pis.username="vossman"
330
WHERE projectdata.pis.username="nramm_vossman"
331
332
UPDATE projectdata.pis
333 1 Amber Herold
SET projectdata.pis.username="ychaban"
334 19 Amber Herold
WHERE projectdata.pis.username="nramm_ychaban"
335
</pre>
336
337 20 Amber Herold
*Add project co-owners (the people who actually access the project).* 
338
Many of the project owners do not actually access the data. Add the users who actually work with the project. 
339 19 Amber Herold
340
<pre>
341
INSERT INTO projectdata.pis (projectId, username)
342 21 Amber Herold
VALUES (200,"nramm_fazam"), (230,"glander"), (190,"jlee"), 
343
(231,"glander"), (203,"Ranjan"), (181,"kubalek"), (84,"strable"), 
344
(222,"nramm_barbie"), (199,"joelq")
345 19 Amber Herold
</pre>
346
347 20 Amber Herold
*Insert rows into projectowners.*
348 19 Amber Herold
All project owners now have usernames in dbemdata.UserData and all projects have an active owner in project.pis. 
349
350
<pre>
351
INSERT INTO projectdata.projectowners (`REF|projects|project`, `REF|leginondata|UserData|user`)
352
SELECT projectdata.pis.projectId, dbemdata.UserData.DEF_id
353
FROM dbemdata.UserData, projectdata.pis
354
WHERE dbemdata.UserData.username = projectdata.pis.username
355 18 Amber Herold
</pre>
356
357 9 Amber Herold
h2. 4 Modify userdetails table
358 3 Amber Herold
359 1 Amber Herold
Remove the email column from the userdetails table.
360 11 Amber Herold
From users, copy all needed fields.
361 14 Amber Herold
362
h3. Copy users from dbemdata.UserData to the project.userdetails table. inserts 188 rows
363
364
<pre>
365 15 Amber Herold
INSERT INTO projectdata.userdetails 
366
  (`REF|leginondata|UserData|user`, 
367
   title, 
368
   institution, 
369
   dept, 
370
   address, 
371
   city, 
372
   statecountry, 
373
   zip, 
374
   phone, 
375
   fax, 
376
   url)
377
SELECT dbemdata.UserData.DEF_id, projectdata.users.title, projectdata.users.institution, 
378
  projectdata.users.dept, projectdata.users.address, projectdata.users.city, 
379
  projectdata.users.statecountry, projectdata.users.zip, projectdata.users.phone, 
380
  projectdata.users.fax, projectdata.users.url
381 14 Amber Herold
FROM dbemdata.UserData, projectdata.users
382
WHERE dbemdata.UserData.username = projectdata.users.username
383
AND projectdata.users.userId NOT IN ( 216, 224, 107, 204, 219, 241, 261 )
384
</pre>
385
386
ignore:
387
project.users.userId username
388
216  	nramm_hetzer (dup w/less data)
389
224  	nramm_hjing
390
107  	nramm_jlanman
391
204  	nramm_rkhayat
392
219  	nramm_rkhayat
393
241  	nramm_vinzenz.unger
394
261  	nramm_vinzenz.unger
395 2 Amber Herold