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

Unified Diff: perf/go/db/db.go

Issue 813443002: Overhaul database package (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: Assume the MySQL password is "" when running locally Created 5 years, 11 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 | « perf/DESIGN.md ('k') | perf/go/db/db_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: perf/go/db/db.go
diff --git a/perf/go/db/db.go b/perf/go/db/db.go
index 56380dce6fedd47bb9a1b502b5654539706a5f4f..8626b038329cb9ad29248f0b681d78940eeee2ea 100644
--- a/perf/go/db/db.go
+++ b/perf/go/db/db.go
@@ -3,28 +3,14 @@ package db
import (
"database/sql"
- "fmt"
-
- "github.com/golang/glog"
"skia.googlesource.com/buildbot.git/go/database"
- "skia.googlesource.com/buildbot.git/go/metadata"
)
const (
- // Key of the password for the readwrite user.
- METADATA_KEY = "readwrite"
-
- // Path where the SQLite database is stored when running locally.
- SQLITE_DB_PATH = "./perf.db"
-
- // Template to generate the database connection string in production.
- // The IP address of the database is found here:
- // https://console.developers.google.com/project/31977622648/sql/instances/skiaperf/overview
- // And 3306 is the default port for MySQL.
- DB_CONN_TMPL = "%s:%s@tcp(173.194.104.24:3306)/skia?parseTime=true"
-
- // Username of the read/write user.
- RW_USER = "readwrite"
+ // Default database parameters.
+ PROD_DB_HOST = "173.194.104.24"
+ PROD_DB_PORT = 3306
+ PROD_DB_NAME = "skia"
)
var (
@@ -37,37 +23,11 @@ func Init(conf *database.DatabaseConfig) {
DB = vdb.DB
}
+// MigrationSteps returns the migration (up and down) for the database.
func MigrationSteps() []database.MigrationStep {
return migrationSteps
}
-// Returns the DB connection string for running in production where a
-// metadata server is available. If 'local' is true it will always return
-// "" (empty string). When used with Init() this will cause it to use a
-// local SQLite database. If it's not local and the meta data server is
-// unreachable it will terminate.
-func ProdDatabaseConfig(local bool) *database.DatabaseConfig {
- mysqlStr := ""
- sqlitePath := SQLITE_DB_PATH
-
- // We are in the production environment, so we look up the parameters.
- if !local {
- // First, get the password from the metadata server.
- // See https://developers.google.com/compute/docs/metadata#custom.
- password, err := metadata.Get(METADATA_KEY)
- if err != nil {
- glog.Fatalf("Failed to find metadata. Use 'local' flag when running locally.")
- }
- mysqlStr, sqlitePath = fmt.Sprintf(DB_CONN_TMPL, RW_USER, password), ""
- }
-
- return &database.DatabaseConfig{
- MySQLString: mysqlStr,
- SQLiteFilePath: sqlitePath,
- MigrationSteps: migrationSteps,
- }
-}
-
// Define the migration steps.
// Note: Only add to this list, once a step has landed in version control it
// must not be changed.
@@ -97,31 +57,6 @@ var migrationSteps = []database.MigrationStep{
)`,
},
MySQLDown: []string{},
- SQLiteUp: []string{
- `CREATE TABLE clusters (
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- ts TIMESTAMP NOT NULL,
- hash TEXT NOT NULL,
- regression FLOAT NOT NULL,
- cluster MEDIUMTEXT NOT NULL,
- status TEXT NOT NULL,
- message TEXT NOT NULL
- )`,
- `CREATE TABLE shortcuts (
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- traces MEDIUMTEXT NOT NULL
- )`,
- `CREATE TABLE tries (
- issue VARCHAR(255) NOT NULL PRIMARY KEY,
- lastUpdated TIMESTAMP NOT NULL,
- results MEDIUMTEXT NOT NULL
- )`,
- },
- SQLiteDown: []string{
- `DROP TABLE IF EXISTS clusters`,
- `DROP TABLE IF EXISTS shortcuts`,
- `DROP TABLE IF EXISTS tries`,
- },
},
// version 2
{
@@ -135,18 +70,6 @@ var migrationSteps = []database.MigrationStep{
)`,
},
MySQLDown: []string{},
- SQLiteUp: []string{
- `CREATE TABLE activitylog (
- id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
- timestamp TIMESTAMP NOT NULL,
- userid TEXT NOT NULL,
- action TEXT NOT NULL,
- url TEXT
- )`,
- },
- SQLiteDown: []string{
- `DROP TABLE IF EXISTS activitylog`,
- },
},
// Use this is a template for more migration steps.
@@ -154,7 +77,5 @@ var migrationSteps = []database.MigrationStep{
// {
// MySQLUp: ,
// MySQLDown: ,
- // SQLiteUp: ,
- // SQLiteDown: ,
// },
}
« no previous file with comments | « perf/DESIGN.md ('k') | perf/go/db/db_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698