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

Side by Side Diff: perf/go/perf_migratedb/main.go

Issue 813443002: Overhaul database package (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Comments/readme cleanup Created 6 years 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
OLDNEW
1 package main 1 package main
2 2
3 // Executes database migrations to the latest target version. In production this 3 // Executes database migrations to the latest target version. In production this
4 // requires the root password for MySQL. The user will be prompted for that so 4 // requires the root password for MySQL. The user will be prompted for that so
5 // it is not entered via the command line. 5 // it is not entered via the command line.
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "os" 11 "os"
12 "strings" 12 "strings"
13 13
14 "github.com/golang/glog" 14 "github.com/golang/glog"
15 "skia.googlesource.com/buildbot.git/go/common" 15 "skia.googlesource.com/buildbot.git/go/common"
16 "skia.googlesource.com/buildbot.git/go/database" 16 "skia.googlesource.com/buildbot.git/go/database"
17 "skia.googlesource.com/buildbot.git/perf/go/db" 17 "skia.googlesource.com/buildbot.git/perf/go/db"
18 ) 18 )
19 19
20 func main() { 20 func main() {
21 » common.Init() 21 » defaultConnStr := fmt.Sprintf(database.DB_CONN_TMPL, database.USER_ROOT, "%s", db.PROD_DB_HOST, db.PROD_DB)
22 » defaultConnStr := strings.Replace(db.DB_CONN_TMPL, "%s", "root", 1)
23 22
24 // flags 23 // flags
25 dbConnString := flag.String("db_conn_string", defaultConnStr, "\n\tDatab ase string to open connect to the MySQL database. "+ 24 dbConnString := flag.String("db_conn_string", defaultConnStr, "\n\tDatab ase string to open connect to the MySQL database. "+
26 "\n\tNeeds to follow the format of the golang-mysql driver (http s://github.com/go-sql-driver/mysql."+ 25 "\n\tNeeds to follow the format of the golang-mysql driver (http s://github.com/go-sql-driver/mysql."+
27 "\n\tIf the string contains %s the user will be prompted to ente r a password which will then be used for subtitution.") 26 "\n\tIf the string contains %s the user will be prompted to ente r a password which will then be used for subtitution.")
28 27
28 common.Init()
29
29 var connectionStr = *dbConnString 30 var connectionStr = *dbConnString
30 31
31 // if it contains formatting information read the password from stdin. 32 // if it contains formatting information read the password from stdin.
32 if strings.Contains(connectionStr, "%s") { 33 if strings.Contains(connectionStr, "%s") {
33 glog.Infof("Using connection string: %s", connectionStr) 34 glog.Infof("Using connection string: %s", connectionStr)
34 reader := bufio.NewReader(os.Stdin) 35 reader := bufio.NewReader(os.Stdin)
35 fmt.Print("Enter password for MySQL: ") 36 fmt.Print("Enter password for MySQL: ")
36 password, err := reader.ReadString('\n') 37 password, err := reader.ReadString('\n')
37 if err != nil { 38 if err != nil {
38 glog.Fatalf("Unable to read password. Error: %s", err) 39 glog.Fatalf("Unable to read password. Error: %s", err)
(...skipping 20 matching lines...) Expand all
59 if dbVersion < maxDBVersion { 60 if dbVersion < maxDBVersion {
60 glog.Infof("Migrating to version: %d", maxDBVersion) 61 glog.Infof("Migrating to version: %d", maxDBVersion)
61 err = vdb.Migrate(maxDBVersion) 62 err = vdb.Migrate(maxDBVersion)
62 if err != nil { 63 if err != nil {
63 glog.Fatalf("Unable to retrieve database version. Error: %s", err) 64 glog.Fatalf("Unable to retrieve database version. Error: %s", err)
64 } 65 }
65 } 66 }
66 67
67 glog.Infoln("Database migration finished.") 68 glog.Infoln("Database migration finished.")
68 } 69 }
OLDNEW
« go/buildbot/db.go ('K') | « perf/go/ingest/main.go ('k') | perf/go/skiaperf/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698