summaryrefslogtreecommitdiff
path: root/scripts/db_migrations/version5.sh
blob: dc5828dc5704dca4584c4c1539ebfc9ece065da0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
#!/bin/sh
# LibreSSL - CAcert web application
# Copyright (C) 2004-2011  CAcert Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA



# script to do database migrations

set -e # script fails if any command fails

STDIN=0
STDOUT=1
STDERR=2

if [ "$1" = "--help" ]; then
	cat >&$STDERR <<- USAGE
		Usage: $0 [MYSQL_OPTIONS]
		You have to specify all options needed by "mysql" as if you had started
		the MySQL command line client directly (including the name of the
		database to operate on). The MySQL user used has to have enough
		privileges to do all necessary operations (among others CREATE, ALTER,
		DROP, UPDATE, INSERT, DELETE).
		You might need to enter the mysql password multiple times if you
		specify the -p option.
	USAGE
	exit 1
fi

mysql_opt=" --batch --skip-column-names $@"

schema_version=$( mysql $mysql_opt <<- 'SQL'

	SELECT MAX(`version`) FROM `schema_version`;
SQL
)
if [ $schema_version != 4 ]; then
	cat >&$STDERR <<- ERROR
		Error: database schema is not in the right version to do the migration!
		Expected version: 4
	ERROR
	exit 2
fi

mysql $mysql_opt <<- 'SQL'

-- Move myISAM to InnoDB bug #1172

ALTER TABLE schema_version ENGINE=INNODB;

echo "table schema_version altered to InnoDB"


ALTER TABLE abuserreports ENGINE=INNODB;

echo "table abusereports altered to InnoDB"


ALTER TABLE addlang ENGINE=INNODB;

echo "table addlang altered to InnoDB"


ALTER TABLE adminlog ENGINE=INNODB;

echo "table adminlog altered to InnoDB"


ALTER TABLE advertising ENGINE=INNODB;

echo "table advertising altered to InnoDB"


ALTER TABLE alerts ENGINE=INNODB;

echo "table alerts altered to InnoDB"


ALTER TABLE baddomains  ENGINE=INNODB;

echo "table baddomains altered to InnoDB"


ALTER TABLE cats_passed  ENGINE=INNODB;

echo "table cats_passed altered to InnoDB"


ALTER TABLE cats_type  ENGINE=INNODB;

echo "table cats_type altered to InnoDB"


ALTER TABLE cats_variant  ENGINE=INNODB;

echo "table cats_variant altered to InnoDB"


ALTER TABLE countries  ENGINE=INNODB;

echo "table countries altered to InnoDB"


ALTER TABLE disputedomain ENGINE=INNODB;

echo "table disputedomain altered to InnoDB"


ALTER TABLE disputeemail ENGINE=INNODB;

echo "table disputeemail altered to InnoDB"


ALTER TABLE gpg  ENGINE=INNODB;

echo "table gpg altered to InnoDB"


ALTER TABLE localias  ENGINE=INNODB;

echo "table localias altered to InnoDB"


ALTER TABLE news  ENGINE=INNODB;

echo "table news altered to InnoDB"


ALTER TABLE otphashes ENGINE=INNODB;

echo "table  otphashes altered to InnoDB"


ALTER TABLE pinglog ENGINE=INNODB;

echo "table pinglog altered to InnoDB"


ALTER TABLE root_certs ENGINE=INNODB;

echo "table root_certs altered to InnoDB"


ALTER TABLE stampcache  ENGINE=INNODB;

echo "table stampcache altered to InnoDB"


ALTER TABLE tickets ENGINE=INNODB;

echo "table tickets altered to InnoDB"


ALTER TABLE languages ENGINE=INNODB;

echo "table languages altered to InnoDB"


ALTER TABLE locations  ENGINE=INNODB;

echo "table locations altered to InnoDB"


ALTER TABLE regions ENGINE=INNODB;

echo "table regions altered to InnoDB"


ALTER TABLE domaincerts  ENGINE=INNODB;

echo "table domainderts altered to InnoDB"


ALTER TABLE domains ENGINE=INNODB;

echo "table domains altered to InnoDB"


ALTER TABLE domLink  ENGINE=INNODB;

echo "table domLink altered to InnoDB"


ALTER TABLE emailcerts  ENGINE=INNODB;

echo "table emailcerts altered to InnoDB"


ALTER TABLE emaillink  ENGINE=INNODB;

echo "table emaillink altered to InnoDB"


ALTER TABLE email  ENGINE=INNODB;

echo "table email altered to InnoDB"


ALTER TABLE notary  ENGINE=INNODB;

echo "table notary altered to InnoDB"


ALTER TABLE tverify ENGINE=INNODB;

echo "table tverify altered to InnoDB"


ALTER TABLE tverify-vote  ENGINE=INNODB;

echo "table tverify-vote altered to InnoDB"


ALTER TABLE userlocations  ENGINE=INNODB;

echo "table userlocations altered to InnoDB"


ALTER TABLE users  ENGINE=INNODB;

echo "table users altered to InnoDB"


ALTER TABLE user_agreements ENGINE=INNODB;

echo "table user_agreements altered to InnoDB"


ALTER TABLE orgdomaincerts  ENGINE=INNODB;

echo "table orgdomaincerts altered to InnoDB"


ALTER TABLE orgdomains  ENGINE=INNODB;

echo "table orgdomains altered to InnoDB"


ALTER TABLE orgdomlink  ENGINE=INNODB;

echo "table orgdomlink altered to InnoDB"


ALTER TABLE orgemailcerts  ENGINE=INNODB;

echo "table orgemailcerts altered to InnoDB"


ALTER TABLE orgemaillink  ENGINE=INNODB;

echo "table orgemaillink altered to InnoDB"


ALTER TABLE orginfo  ENGINE=INNODB;

echo "table orginfo altered to InnoDB"


ALTER TABLE org  ENGINE=INNODB;

echo "table org altered to InnoDB"


ALTER TABLE statscache  ENGINE=INNODB;

echo "table statscache altered to InnoDB"


	-- Update schema version number
	INSERT INTO `schema_version`
		(`version`, `when`) VALUES
		('5'      , NOW() );
SQL


echo "Database successfully migrated to version 5"
exit 0