From 2a512d144871580fc51b5becb62205695b861221 Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 22 Apr 2019 16:14:17 -0700 Subject: [PATCH] fix postgres migration error --- store/shared/db/dbtest/dbtest.go | 7 ++++--- store/shared/migrate/postgres/ddl_gen.go | 2 +- .../postgres/files/012_create_table_org_secrets.sql | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/store/shared/db/dbtest/dbtest.go b/store/shared/db/dbtest/dbtest.go index b2e43b65..0fb780a8 100644 --- a/store/shared/db/dbtest/dbtest.go +++ b/store/shared/db/dbtest/dbtest.go @@ -33,9 +33,9 @@ func Connect() (*db.DB, error) { driver = "sqlite3" config = ":memory:?_foreign_keys=1" ) - if os.Getenv("DATABASE_DRIVER") != "" { - driver = os.Getenv("DATABASE_DRIVER") - config = os.Getenv("DATABASE_CONFIG") + if os.Getenv("DRONE_DATABASE_DRIVER") != "" { + driver = os.Getenv("DRONE_DATABASE_DRIVER") + config = os.Getenv("DRONE_DATABASE_DATASOURCE") } return db.Connect(driver, config) } @@ -51,6 +51,7 @@ func Reset(d *db.DB) { tx.Exec("DELETE FROM perms") tx.Exec("DELETE FROM repos") tx.Exec("DELETE FROM users") + tx.Exec("DELETE FROM orgsecrets") return nil }) } diff --git a/store/shared/migrate/postgres/ddl_gen.go b/store/shared/migrate/postgres/ddl_gen.go index 08ac0450..7246dad7 100644 --- a/store/shared/migrate/postgres/ddl_gen.go +++ b/store/shared/migrate/postgres/ddl_gen.go @@ -545,7 +545,7 @@ ALTER TABLE builds ADD COLUMN build_cron VARCHAR(50) NOT NULL DEFAULT ''; var createTableOrgSecrets = ` CREATE TABLE IF NOT EXISTS orgsecrets ( - secret_id INTEGER PRIMARY KEY AUTOINCREMENT + secret_id SERIAL PRIMARY KEY ,secret_namespace VARCHAR(50) ,secret_name VARCHAR(200) ,secret_type VARCHAR(50) diff --git a/store/shared/migrate/postgres/files/012_create_table_org_secrets.sql b/store/shared/migrate/postgres/files/012_create_table_org_secrets.sql index 269f7aed..7541ff06 100644 --- a/store/shared/migrate/postgres/files/012_create_table_org_secrets.sql +++ b/store/shared/migrate/postgres/files/012_create_table_org_secrets.sql @@ -1,7 +1,7 @@ -- name: create-table-org-secrets CREATE TABLE IF NOT EXISTS orgsecrets ( - secret_id INTEGER PRIMARY KEY AUTOINCREMENT + secret_id SERIAL PRIMARY KEY ,secret_namespace VARCHAR(50) ,secret_name VARCHAR(200) ,secret_type VARCHAR(50)