Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: chrome/browser/webdata/keyword_table.cc

Issue 6677124: Move migration code out of WebDatabase and into table-specific classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/webdata/keyword_table.h" 5 #include "chrome/browser/webdata/keyword_table.h"
6 6
7 #include "app/sql/statement.h" 7 #include "app/sql/statement.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 219
220 bool KeywordTable::SetBuitinKeywordVersion(int version) { 220 bool KeywordTable::SetBuitinKeywordVersion(int version) {
221 return meta_table_->SetValue(kBuiltinKeywordVersion, version); 221 return meta_table_->SetValue(kBuiltinKeywordVersion, version);
222 } 222 }
223 223
224 int KeywordTable::GetBuitinKeywordVersion() { 224 int KeywordTable::GetBuitinKeywordVersion() {
225 int version = 0; 225 int version = 0;
226 meta_table_->GetValue(kBuiltinKeywordVersion, &version); 226 meta_table_->GetValue(kBuiltinKeywordVersion, &version);
227 return version; 227 return version;
228 } 228 }
229
230 bool KeywordTable::AddAutoGenerateKeywordColumnForVersion21() {
231 return db_->Execute("ALTER TABLE keywords ADD COLUMN autogenerate_keyword "
232 "INTEGER DEFAULT 0");
233 }
234
235 bool KeywordTable::AddLogoIDColumnForVersionVersion25() {
236 return db_->Execute(
237 "ALTER TABLE keywords ADD COLUMN logo_id INTEGER DEFAULT 0");
238 }
239
240 bool KeywordTable::AddCreatedByPolicyColumnForVersion26() {
241 return db_->Execute("ALTER TABLE keywords ADD COLUMN created_by_policy "
242 "INTEGER DEFAULT 0");
243 }
244
245 bool KeywordTable::AddSupportsInstantColumnForVersion28() {
246 return db_->Execute("ALTER TABLE keywords ADD COLUMN supports_instant "
247 "INTEGER DEFAULT 0");
248 }
249
250 bool KeywordTable::ChangeInstantUrlToSupportsInstantForVersion29() {
251 if (!db_->Execute("ALTER TABLE keywords ADD COLUMN instant_url VARCHAR"))
252 return false;
253
254 if (!db_->Execute("CREATE TABLE keywords_temp ("
255 "id INTEGER PRIMARY KEY,"
256 "short_name VARCHAR NOT NULL,"
257 "keyword VARCHAR NOT NULL,"
258 "favicon_url VARCHAR NOT NULL,"
259 "url VARCHAR NOT NULL,"
260 "show_in_default_list INTEGER,"
261 "safe_for_autoreplace INTEGER,"
262 "originating_url VARCHAR,"
263 "date_created INTEGER DEFAULT 0,"
264 "usage_count INTEGER DEFAULT 0,"
265 "input_encodings VARCHAR,"
266 "suggest_url VARCHAR,"
267 "prepopulate_id INTEGER DEFAULT 0,"
268 "autogenerate_keyword INTEGER DEFAULT 0,"
269 "logo_id INTEGER DEFAULT 0,"
270 "created_by_policy INTEGER DEFAULT 0,"
271 "instant_url VARCHAR)")) {
272 return false;
273 }
274
275 if (!db_->Execute(
276 "INSERT INTO keywords_temp "
277 "SELECT id, short_name, keyword, favicon_url, url, "
278 "show_in_default_list, safe_for_autoreplace, originating_url, "
279 "date_created, usage_count, input_encodings, suggest_url, "
280 "prepopulate_id, autogenerate_keyword, logo_id, created_by_policy, "
281 "instant_url FROM keywords")) {
282 return false;
283 }
284
285 if (!db_->Execute("DROP TABLE keywords"))
286 return false;
287
288 if (!db_->Execute("ALTER TABLE keywords_temp RENAME TO keywords"))
289 return false;
290
291 return true;
292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698