Project

General

Profile

DB Migration Process » History » Version 23

Amber Herold, 02/09/2010 02:02 PM

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