Project

General

Profile

DB Migration Process » History » Version 19

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