DB Migration Process » History » Version 18
Amber Herold, 02/09/2010 12:05 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 | 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 | <pre> |
||
200 | //Insert rows into projectowners |
||
201 | INSERT INTO projectdata.projectowners (`REF|projects|project`, `REF|leginondata|UserData|user`) |
||
202 | SELECT projectdata.pis.projectId, dbemdata.UserData.DEF_id |
||
203 | FROM dbemdata.UserData, projectdata.pis |
||
204 | WHERE dbemdata.UserData.username = projectdata.pis.username |
||
205 | |||
206 | Inserts 95 pis. |
||
207 | Then need to add the rest: |
||
208 | |||
209 | //users that do not have login info and do not have a dbem user name. |
||
210 | //Set the passwords to the username. |
||
211 | |||
212 | INSERT INTO dbemdata.UserData (username, firstname, lastname, email, password) |
||
213 | SELECT projectdata.users.username,projectdata.users.firstname, projectdata.users.lastname, projectdata.users.email, projectdata.users.username |
||
214 | FROM projectdata.users |
||
215 | WHERE projectdata.users.userId IN (229, 262,263,208,209,265,278, 235,256,196,267,217,255,266,274,228,289) |
||
216 | |||
217 | // Add their details into th userdetails table |
||
218 | |||
219 | INSERT INTO projectdata.userdetails (`REF|leginondata|UserData|user`, title, institution, dept, address, city, statecountry, zip, phone, fax, url) |
||
220 | 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 |
||
221 | FROM dbemdata.UserData, projectdata.users |
||
222 | WHERE dbemdata.UserData.username = projectdata.users.username |
||
223 | AND projectdata.users.userId IN ( 229, 262,263,208,209,265,278, 235,256,196,267,217,255,266,274,228,289) |
||
224 | </pre> |
||
225 | |||
226 | 9 | Amber Herold | h2. 4 Modify userdetails table |
227 | 3 | Amber Herold | |
228 | 1 | Amber Herold | Remove the email column from the userdetails table. |
229 | 11 | Amber Herold | From users, copy all needed fields. |
230 | 14 | Amber Herold | |
231 | h3. Copy users from dbemdata.UserData to the project.userdetails table. inserts 188 rows |
||
232 | |||
233 | <pre> |
||
234 | 15 | Amber Herold | INSERT INTO projectdata.userdetails |
235 | (`REF|leginondata|UserData|user`, |
||
236 | title, |
||
237 | institution, |
||
238 | dept, |
||
239 | address, |
||
240 | city, |
||
241 | statecountry, |
||
242 | zip, |
||
243 | phone, |
||
244 | fax, |
||
245 | url) |
||
246 | SELECT dbemdata.UserData.DEF_id, projectdata.users.title, projectdata.users.institution, |
||
247 | projectdata.users.dept, projectdata.users.address, projectdata.users.city, |
||
248 | projectdata.users.statecountry, projectdata.users.zip, projectdata.users.phone, |
||
249 | projectdata.users.fax, projectdata.users.url |
||
250 | 14 | Amber Herold | FROM dbemdata.UserData, projectdata.users |
251 | WHERE dbemdata.UserData.username = projectdata.users.username |
||
252 | AND projectdata.users.userId NOT IN ( 216, 224, 107, 204, 219, 241, 261 ) |
||
253 | </pre> |
||
254 | |||
255 | ignore: |
||
256 | project.users.userId username |
||
257 | 216 nramm_hetzer (dup w/less data) |
||
258 | 224 nramm_hjing |
||
259 | 107 nramm_jlanman |
||
260 | 204 nramm_rkhayat |
||
261 | 219 nramm_rkhayat |
||
262 | 241 nramm_vinzenz.unger |
||
263 | 261 nramm_vinzenz.unger |
||
264 | 2 | Amber Herold |