fix cockroach init to create table in correct database (#1977)
This commit is contained in:
parent
a60426c884
commit
6e30b53280
@ -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")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user