fix cockroach init to create table in correct database (#1977)

This commit is contained in:
Dominic Wong 2020-08-28 10:35:47 +01:00 committed by GitHub
parent a60426c884
commit 6e30b53280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,20 +98,15 @@ func (s *sqlStore) initDB(database, table string) error {
return err return err
} }
_, err = s.db.Exec(fmt.Sprintf("SET DATABASE = %s;", database))
if err != nil {
return errors.Wrap(err, "Couldn't set database")
}
// Create a table for the namespace's prefix // Create a table for the namespace's prefix
_, err = s.db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s _, err = s.db.Exec(fmt.Sprintf(`CREATE TABLE IF NOT EXISTS %s.%s
( (
key text NOT NULL, key text NOT NULL,
value bytea, value bytea,
metadata JSONB, metadata JSONB,
expiry timestamp with time zone, expiry timestamp with time zone,
CONSTRAINT %s_pkey PRIMARY KEY (key) CONSTRAINT %s_pkey PRIMARY KEY (key)
);`, table, table)) );`, database, table, table))
if err != nil { if err != nil {
return errors.Wrap(err, "Couldn't create table") return errors.Wrap(err, "Couldn't create table")
} }