satellite: add ctx to DB.CreateTables
Change-Id: I9ecad624cf5a7fc9c86bb91c68f96a3a4efd2e92
This commit is contained in:
parent
0835b9024c
commit
24958bd7d3
@ -248,7 +248,9 @@ func cmdRun(cmd *cobra.Command, args []string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func cmdMigrationRun(cmd *cobra.Command, args []string) (err error) {
|
func cmdMigrationRun(cmd *cobra.Command, args []string) (err error) {
|
||||||
|
ctx, _ := process.Ctx(cmd)
|
||||||
log := zap.L()
|
log := zap.L()
|
||||||
|
|
||||||
db, err := satellitedb.New(log.Named("migration"), runCfg.Database, satellitedb.Options{})
|
db, err := satellitedb.New(log.Named("migration"), runCfg.Database, satellitedb.Options{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.New("Error creating new master database connection for satellitedb migration: %+v", err)
|
return errs.New("Error creating new master database connection for satellitedb migration: %+v", err)
|
||||||
@ -257,7 +259,7 @@ func cmdMigrationRun(cmd *cobra.Command, args []string) (err error) {
|
|||||||
err = errs.Combine(err, db.Close())
|
err = errs.Combine(err, db.Close())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = db.CreateTables()
|
err = db.CreateTables(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.New("Error creating tables for master database on satellite: %+v", err)
|
return errs.New("Error creating tables for master database on satellite: %+v", err)
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ func (planet *Planet) newSatellites(count int) ([]*SatelliteSystem, error) {
|
|||||||
return xs, err
|
return xs, err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = db.CreateTables()
|
err = db.CreateTables(context.TODO())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
package satellite
|
package satellite
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"gopkg.in/spacemonkeygo/monkit.v2"
|
"gopkg.in/spacemonkeygo/monkit.v2"
|
||||||
|
|
||||||
"storj.io/common/identity"
|
"storj.io/common/identity"
|
||||||
@ -45,7 +47,7 @@ var mon = monkit.Package()
|
|||||||
// architecture: Master Database
|
// architecture: Master Database
|
||||||
type DB interface {
|
type DB interface {
|
||||||
// CreateTables initializes the database
|
// CreateTables initializes the database
|
||||||
CreateTables() error
|
CreateTables(ctx context.Context) error
|
||||||
// CheckVersion checks the database is the correct version
|
// CheckVersion checks the database is the correct version
|
||||||
CheckVersion() error
|
CheckVersion() error
|
||||||
// Close closes the database
|
// Close closes the database
|
||||||
|
@ -23,9 +23,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// CreateTables is a method for creating all tables for database
|
// CreateTables is a method for creating all tables for database
|
||||||
func (db *satelliteDB) CreateTables() error {
|
func (db *satelliteDB) CreateTables(ctx context.Context) error {
|
||||||
ctx := context.TODO()
|
|
||||||
|
|
||||||
// First handle the idiosyncrasies of postgres and cockroach migrations. Postgres
|
// First handle the idiosyncrasies of postgres and cockroach migrations. Postgres
|
||||||
// will need to create any schemas specified in the search path, and cockroach
|
// will need to create any schemas specified in the search path, and cockroach
|
||||||
// will need to create the database it was told to connect to. These things should
|
// will need to create the database it was told to connect to. These things should
|
||||||
|
@ -185,7 +185,7 @@ func Run(t *testing.T, test func(t *testing.T, db satellite.DB)) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = db.CreateTables()
|
err = db.CreateTables(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ func Bench(b *testing.B, bench func(b *testing.B, db satellite.DB)) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = db.CreateTables()
|
err = db.CreateTables(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user