DB Migration Process » History » Version 13
Amber Herold, 02/03/2010 02:56 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 | h2. 3 Create projectowner table |
||
172 | |||
173 | 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. |
||
174 | We will phase out use of the pis table. |
||
175 | |||
176 | 9 | Amber Herold | h2. 4 Modify userdetails table |
177 | 3 | Amber Herold | |
178 | 1 | Amber Herold | Remove the email column from the userdetails table. |
179 | 11 | Amber Herold | From users, copy all needed fields. |
180 | 2 | Amber Herold |