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

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

Issue 813443002: Overhaul database package (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: perf/go/db/db.go
diff --git a/perf/go/db/db.go b/perf/go/db/db.go
index 56380dce6fedd47bb9a1b502b5654539706a5f4f..fda489518ae785f87ee7f94f9d23ccfe194bf71a 100644
--- a/perf/go/db/db.go
+++ b/perf/go/db/db.go
@@ -14,9 +14,6 @@ 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
@@ -44,11 +41,10 @@ func MigrationSteps() []database.MigrationStep {
// 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
+// local MySQL test 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 {
@@ -58,14 +54,16 @@ func ProdDatabaseConfig(local bool) *database.DatabaseConfig {
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), ""
+ mysqlStr = fmt.Sprintf(DB_CONN_TMPL, RW_USER, password)
}
- return &database.DatabaseConfig{
- MySQLString: mysqlStr,
- SQLiteFilePath: sqlitePath,
- MigrationSteps: migrationSteps,
+ if mysqlStr != "" {
+ return &database.DatabaseConfig{
+ MySQLString: mysqlStr,
+ MigrationSteps: migrationSteps,
+ }
}
+ return database.LocalTestDatabaseConfig(migrationSteps)
}
// Define the migration steps.
@@ -97,31 +95,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 +108,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 +115,5 @@ var migrationSteps = []database.MigrationStep{
// {
// MySQLUp: ,
// MySQLDown: ,
- // SQLiteUp: ,
- // SQLiteDown: ,
// },
}
« golden/go/db/db.go ('K') | « 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