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

Unified Diff: experimental/webtry/webtry.go

Issue 613593002: webtry: Only create sqlite3 tables if they don't exist yet. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/webtry/webtry.go
diff --git a/experimental/webtry/webtry.go b/experimental/webtry/webtry.go
index fd512de9d88da1900079fda72cc34692a9ad842a..a4fe9e0ef5a12c75a2cbfa655049c8cb05c46e65 100644
--- a/experimental/webtry/webtry.go
+++ b/experimental/webtry/webtry.go
@@ -238,7 +238,7 @@ func init() {
log.Printf("ERROR: Failed to open: %q\n", err)
panic(err)
}
- sql := `CREATE TABLE source_images (
+ sql := `CREATE TABLE IF NOT EXISTS source_images (
id INTEGER PRIMARY KEY NOT NULL,
image MEDIUMBLOB DEFAULT '' NOT NULL, -- formatted as a PNG.
width INTEGER DEFAULT 0 NOT NULL,
@@ -247,9 +247,11 @@ func init() {
hidden INTEGER DEFAULT 0 NOT NULL
)`
_, err = db.Exec(sql)
- log.Printf("Info: status creating sqlite table for sources: %q\n", err)
+ if err != nil {
+ log.Printf("Info: status creating sqlite table for sources: %q\n", err)
+ }
- sql = `CREATE TABLE webtry (
+ sql = `CREATE TABLE IF NOT EXISTS webtry (
code TEXT DEFAULT '' NOT NULL,
create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
hash CHAR(64) DEFAULT '' NOT NULL,
@@ -258,17 +260,21 @@ func init() {
PRIMARY KEY(hash)
)`
_, err = db.Exec(sql)
- log.Printf("Info: status creating sqlite table for webtry: %q\n", err)
+ if err != nil {
+ log.Printf("Info: status creating sqlite table for webtry: %q\n", err)
+ }
- sql = `CREATE TABLE workspace (
+ sql = `CREATE TABLE IF NOT EXISTS workspace (
name CHAR(64) DEFAULT '' NOT NULL,
create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
PRIMARY KEY(name)
)`
_, err = db.Exec(sql)
- log.Printf("Info: status creating sqlite table for workspace: %q\n", err)
+ if err != nil {
+ log.Printf("Info: status creating sqlite table for workspace: %q\n", err)
+ }
- sql = `CREATE TABLE workspacetry (
+ sql = `CREATE TABLE IF NOT EXISTS workspacetry (
name CHAR(64) DEFAULT '' NOT NULL,
create_ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
hash CHAR(64) DEFAULT '' NOT NULL,
@@ -278,7 +284,9 @@ func init() {
FOREIGN KEY (name) REFERENCES workspace(name)
)`
_, err = db.Exec(sql)
- log.Printf("Info: status creating sqlite table for workspace try: %q\n", err)
+ if err != nil {
+ log.Printf("Info: status creating sqlite table for workspace try: %q\n", err)
+ }
}
// Ping the database to keep the connection fresh.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698