Update primary error functions to take a context, deprecate old functions (#1358)
* add new error funcs which take a ctx and deprecate existing funcs * use context where available when writing error events * remove circular internal/errors pkg dep * suppress some chatty errors using errors.WithoutEvent() * convert auth oidc funcs to take context where needed to write events Co-authored-by: Jim <jlambert@hashicorp.com>
This commit is contained in:
1 parent
02ff2db66e
commit
6b78108ecf
227 files changed
+3945
-3736
No files matched your search
@@ -63,10 +63,10 @@ func NewManager(ctx context.Context, dialect string, db *sql.DB, opt ...Option)
|
||||
var err error
|
||||
dbM.driver, err = postgres.New(ctx, db)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
default:
|
||||
return nil, errors.New(errors.InvalidParameter, op, fmt.Sprintf("unknown dialect %q", dialect))
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, fmt.Sprintf("unknown dialect %q", dialect))
|
||||
}
|
||||
return &dbM, nil
|
||||
}
|
||||
@@ -92,7 +92,7 @@ func (b *Manager) CurrentState(ctx context.Context) (*State, error) {
|
||||
|
||||
v, initialized, dirty, err := b.driver.CurrentState(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
dbS.InitializationStarted = initialized
|
||||
dbS.DatabaseSchemaVersion = v
|
||||
@@ -106,7 +106,7 @@ func (b *Manager) CurrentState(ctx context.Context) (*State, error) {
|
||||
func (b *Manager) SharedLock(ctx context.Context) error {
|
||||
const op = "schema.(Manager).SharedLock"
|
||||
if err := b.driver.TrySharedLock(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func (b *Manager) SharedLock(ctx context.Context) error {
|
||||
func (b *Manager) SharedUnlock(ctx context.Context) error {
|
||||
const op = "schema.(Manager).SharedUnlock"
|
||||
if err := b.driver.UnlockShared(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -127,7 +127,7 @@ func (b *Manager) SharedUnlock(ctx context.Context) error {
|
||||
func (b *Manager) ExclusiveLock(ctx context.Context) error {
|
||||
const op = "schema.(Manager).ExclusiveLock"
|
||||
if err := b.driver.TryLock(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func (b *Manager) ExclusiveLock(ctx context.Context) error {
|
||||
func (b *Manager) ExclusiveUnlock(ctx context.Context) error {
|
||||
const op = "schema.(Manager).ExclusiveUnlock"
|
||||
if err := b.driver.Unlock(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -151,27 +151,27 @@ func (b *Manager) RollForward(ctx context.Context) error {
|
||||
|
||||
// Capturing a lock that this session to the db already possesses is okay.
|
||||
if err := b.driver.Lock(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
defer func() {
|
||||
if err := b.driver.Unlock(ctx); err != nil {
|
||||
// I'm not sure this is ideal, but we have to rollback the current
|
||||
// transaction if we're unable to release the lock
|
||||
panic(errors.Wrap(err, op))
|
||||
panic(errors.Wrap(ctx, err, op))
|
||||
}
|
||||
}()
|
||||
|
||||
curVersion, _, dirty, err := b.driver.CurrentState(ctx)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
if dirty {
|
||||
return errors.New(errors.NotSpecificIntegrity, op, fmt.Sprintf("schema is dirty with version %d", curVersion))
|
||||
return errors.New(ctx, errors.NotSpecificIntegrity, op, fmt.Sprintf("schema is dirty with version %d", curVersion))
|
||||
}
|
||||
|
||||
if err = b.runMigrations(ctx, newStatementProvider(b.dialect, curVersion, WithMigrationStates(b.migrationStates))); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -187,10 +187,10 @@ func (b *Manager) runMigrations(ctx context.Context, qp *statementProvider) erro
|
||||
const op = "schema.(Manager).runMigrations"
|
||||
|
||||
if err := b.driver.StartRun(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if err := b.driver.EnsureVersionTable(ctx); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
for qp.Next() {
|
||||
select {
|
||||
@@ -201,16 +201,16 @@ func (b *Manager) runMigrations(ctx context.Context, qp *statementProvider) erro
|
||||
err = multierror.Append(err, rbErr)
|
||||
}
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
default:
|
||||
// context is not done yet. Continue on to the next query to execute.
|
||||
}
|
||||
if err := b.driver.Run(ctx, bytes.NewReader(qp.ReadUp()), qp.Version()); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
if err := b.driver.CommitRun(); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -230,11 +230,11 @@ func GetMigrationLog(ctx context.Context, d *sql.DB, opt ...Option) ([]LogEntry,
|
||||
const op = "schema.GetMigrationLog"
|
||||
const sql = "select id, create_time, migration_version, entry from log_migration where migration_version in (select max(version) from boundary_schema_version)"
|
||||
if d == nil {
|
||||
return nil, errors.New(errors.InvalidParameter, op, "missing sql db")
|
||||
return nil, errors.New(ctx, errors.InvalidParameter, op, "missing sql db")
|
||||
}
|
||||
rows, err := d.QueryContext(ctx, sql)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
@@ -242,19 +242,19 @@ func GetMigrationLog(ctx context.Context, d *sql.DB, opt ...Option) ([]LogEntry,
|
||||
for rows.Next() {
|
||||
var e LogEntry
|
||||
if err := rows.Scan(&e.Id, &e.CreateTime, &e.MigrationVersion, &e.Entry); err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
entries = append(entries, e)
|
||||
}
|
||||
if rows.Err() != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
opts := getOpts(opt...)
|
||||
if opts.withDeleteLog {
|
||||
// this truncate could change to a delete if FKs are needed in the future
|
||||
_, err = d.ExecContext(ctx, "truncate log_migration")
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
return entries, nil
|
||||
|
||||
@@ -24,11 +24,11 @@ func Test_AuthMethodSubtypes(t *testing.T) {
|
||||
kmsCache := kms.TestKms(t, conn, rootWrapper)
|
||||
iamRepo := iam.TestRepo(t, conn, rootWrapper)
|
||||
org, _ := iam.TestScopes(t, iamRepo)
|
||||
oidcRepo, err := oidc.NewRepository(rw, rw, kmsCache)
|
||||
oidcRepo, err := oidc.NewRepository(ctx, rw, rw, kmsCache)
|
||||
require.NoError(err)
|
||||
|
||||
// test oidc subtype insert
|
||||
oidcAm, err := oidc.NewAuthMethod(org.PublicId, "alice-rp", "fido", oidc.WithName("alice"))
|
||||
oidcAm, err := oidc.NewAuthMethod(ctx, org.PublicId, "alice-rp", "fido", oidc.WithName("alice"))
|
||||
require.NoError(err)
|
||||
oidcAm, err = oidcRepo.CreateAuthMethod(ctx, oidcAm)
|
||||
require.NoError(err)
|
||||
|
||||
@@ -66,11 +66,11 @@ type Postgres struct {
|
||||
func New(ctx context.Context, instance *sql.DB) (*Postgres, error) {
|
||||
const op = "postgres.New"
|
||||
if err := instance.PingContext(ctx); err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
conn, err := instance.Conn(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, op)
|
||||
return nil, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
px := &Postgres{
|
||||
@@ -87,14 +87,14 @@ func (p *Postgres) TrySharedLock(ctx context.Context) error {
|
||||
const query = "select pg_try_advisory_lock_shared($1)"
|
||||
r := p.conn.QueryRowContext(ctx, query, schemaAccessLockId)
|
||||
if r.Err() != nil {
|
||||
return errors.Wrap(r.Err(), op)
|
||||
return errors.Wrap(ctx, r.Err(), op)
|
||||
}
|
||||
var gotLock bool
|
||||
if err := r.Scan(&gotLock); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if !gotLock {
|
||||
return errors.New(errors.MigrationLock, op, "Lock failed")
|
||||
return errors.New(ctx, errors.MigrationLock, op, "Lock failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -106,14 +106,14 @@ func (p *Postgres) TryLock(ctx context.Context) error {
|
||||
const query = "select pg_try_advisory_lock($1)"
|
||||
r := p.conn.QueryRowContext(ctx, query, schemaAccessLockId)
|
||||
if r.Err() != nil {
|
||||
return errors.Wrap(r.Err(), op)
|
||||
return errors.Wrap(ctx, r.Err(), op)
|
||||
}
|
||||
var gotLock bool
|
||||
if err := r.Scan(&gotLock); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if !gotLock {
|
||||
return errors.New(errors.MigrationLock, op, "Lock failed")
|
||||
return errors.New(ctx, errors.MigrationLock, op, "Lock failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -124,7 +124,7 @@ func (p *Postgres) Lock(ctx context.Context) error {
|
||||
const op = "postgres.(Postgres).Lock"
|
||||
const query = "select pg_advisory_lock($1)"
|
||||
if _, err := p.conn.ExecContext(ctx, query, schemaAccessLockId); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -135,7 +135,7 @@ func (p *Postgres) Unlock(ctx context.Context) error {
|
||||
const op = "postgres.(Postgres).Unlock"
|
||||
const query = `select pg_advisory_unlock($1)`
|
||||
if _, err := p.conn.ExecContext(ctx, query, schemaAccessLockId); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -146,7 +146,7 @@ func (p *Postgres) UnlockShared(ctx context.Context) error {
|
||||
const op = "postgres.(Postgres).UnlockShared"
|
||||
query := `select pg_advisory_unlock_shared($1)`
|
||||
if _, err := p.conn.ExecContext(ctx, query, schemaAccessLockId); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -159,10 +159,10 @@ func (p *Postgres) Rollback() error {
|
||||
p.tx = nil
|
||||
}()
|
||||
if p.tx == nil {
|
||||
return errors.New(errors.MigrationIntegrity, op, "no pending transaction")
|
||||
return errors.NewDeprecated(errors.MigrationIntegrity, op, "no pending transaction")
|
||||
}
|
||||
if err := p.tx.Rollback(); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.WrapDeprecated(err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -184,13 +184,13 @@ func (p *Postgres) CommitRun() error {
|
||||
p.tx = nil
|
||||
}()
|
||||
if p.tx == nil {
|
||||
return errors.New(errors.MigrationIntegrity, op, "no pending transaction")
|
||||
return errors.NewDeprecated(errors.MigrationIntegrity, op, "no pending transaction")
|
||||
}
|
||||
if err := p.tx.Commit(); err != nil {
|
||||
if errRollback := p.tx.Rollback(); errRollback != nil {
|
||||
err = multierror.Append(err, errRollback)
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.WrapDeprecated(err, op)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -207,7 +207,7 @@ func (p *Postgres) Run(ctx context.Context, migration io.Reader, version int) er
|
||||
const op = "postgres.(Postgres).Run"
|
||||
migr, err := ioutil.ReadAll(migration)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
// Run migration
|
||||
query := string(migr)
|
||||
@@ -225,7 +225,7 @@ func (p *Postgres) Run(ctx context.Context, migration io.Reader, version int) er
|
||||
// set the version first, so logs will be associated with this new version.
|
||||
// if there's an error, it will get rollback
|
||||
if err := p.setVersion(ctx, version, false); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
if _, err := extr.ExecContext(ctx, query); err != nil {
|
||||
@@ -249,9 +249,9 @@ func (p *Postgres) Run(ctx context.Context, migration io.Reader, version int) er
|
||||
message = fmt.Sprintf("%s, %s", message, pgErr.Detail)
|
||||
}
|
||||
message = fmt.Sprintf("%s, on line %v: %s", message, line, migr)
|
||||
return errors.Wrap(err, op, errors.WithMsg(message))
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg(message))
|
||||
}
|
||||
return errors.Wrap(err, op, errors.WithMsg(fmt.Sprintf("migration failed: %s", migr)))
|
||||
return errors.Wrap(ctx, err, op, errors.WithMsg(fmt.Sprintf("migration failed: %s", migr)))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -314,7 +314,7 @@ func (p *Postgres) setVersion(ctx context.Context, version int, dirty bool) erro
|
||||
if errRollback := rollback(); errRollback != nil {
|
||||
err = multierror.Append(err, errRollback)
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
// Also re-write the schema Version for nil dirty versions to prevent
|
||||
@@ -327,13 +327,13 @@ func (p *Postgres) setVersion(ctx context.Context, version int, dirty bool) erro
|
||||
if errRollback := rollback(); errRollback != nil {
|
||||
err = multierror.Append(err, errRollback)
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
|
||||
if p.tx == nil {
|
||||
if err := tx.Commit(); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -351,7 +351,7 @@ func (p *Postgres) CurrentState(ctx context.Context) (version int, previouslyRan
|
||||
tableQuery := `select table_name from information_schema.tables where table_schema=(select current_schema()) and table_name in ('schema_migrations', '` + defaultMigrationsTable + `')`
|
||||
tableResult, err := p.conn.QueryContext(ctx, tableQuery)
|
||||
if err != nil {
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(err, op)
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
defer tableResult.Close()
|
||||
if !tableResult.Next() {
|
||||
@@ -361,17 +361,17 @@ func (p *Postgres) CurrentState(ctx context.Context) (version int, previouslyRan
|
||||
|
||||
tableName := defaultMigrationsTable
|
||||
if err := tableResult.Scan(&tableName); err != nil {
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(err, op)
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
previouslyRan = true
|
||||
if tableResult.Next() {
|
||||
return nilVersion, previouslyRan, dirty, errors.New(errors.MigrationIntegrity, op, "both old and new migration tables exist")
|
||||
return nilVersion, previouslyRan, dirty, errors.New(ctx, errors.MigrationIntegrity, op, "both old and new migration tables exist")
|
||||
}
|
||||
|
||||
query := `select version, dirty from ` + pq.QuoteIdentifier(tableName)
|
||||
results, err := p.conn.QueryContext(ctx, query)
|
||||
if err != nil {
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(err, op)
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
defer results.Close()
|
||||
if !results.Next() {
|
||||
@@ -379,10 +379,10 @@ func (p *Postgres) CurrentState(ctx context.Context) (version int, previouslyRan
|
||||
return nilVersion, previouslyRan, dirty, nil
|
||||
}
|
||||
if err := results.Scan(&version, &dirty); err != nil {
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(err, op)
|
||||
return nilVersion, previouslyRan, dirty, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if results.Next() {
|
||||
return nilVersion, previouslyRan, dirty, errors.New(errors.MigrationIntegrity, op, "to many versions in version table")
|
||||
return nilVersion, previouslyRan, dirty, errors.New(ctx, errors.MigrationIntegrity, op, "to many versions in version table")
|
||||
}
|
||||
return version, previouslyRan, dirty, nil
|
||||
}
|
||||
@@ -393,12 +393,12 @@ func (p *Postgres) drop(ctx context.Context) (err error) {
|
||||
query := `select table_name from information_schema.tables where table_schema=(select current_schema()) and table_type='BASE TABLE'`
|
||||
tables, err := p.conn.QueryContext(ctx, query)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
defer func() {
|
||||
if errClose := tables.Close(); errClose != nil {
|
||||
err = multierror.Append(err, errClose)
|
||||
err = errors.Wrap(err, op)
|
||||
err = errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -407,14 +407,14 @@ func (p *Postgres) drop(ctx context.Context) (err error) {
|
||||
for tables.Next() {
|
||||
var tableName string
|
||||
if err := tables.Scan(&tableName); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if len(tableName) > 0 {
|
||||
tableNames = append(tableNames, tableName)
|
||||
}
|
||||
}
|
||||
if err := tables.Err(); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
if len(tableNames) > 0 {
|
||||
@@ -422,7 +422,7 @@ func (p *Postgres) drop(ctx context.Context) (err error) {
|
||||
for _, t := range tableNames {
|
||||
query = `drop table if exists ` + pq.QuoteIdentifier(t) + ` cascade`
|
||||
if _, err := p.conn.ExecContext(ctx, query); err != nil {
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -450,7 +450,7 @@ func (p *Postgres) EnsureVersionTable(ctx context.Context) (err error) {
|
||||
if wpErr := rollback(); wpErr != nil {
|
||||
err = multierror.Append(err, wpErr)
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if exists {
|
||||
return nil
|
||||
@@ -461,7 +461,7 @@ func (p *Postgres) EnsureVersionTable(ctx context.Context) (err error) {
|
||||
if wpErr := rollback(); wpErr != nil {
|
||||
err = multierror.Append(err, wpErr)
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
createStmt := `create table if not exists ` + pq.QuoteIdentifier(defaultMigrationsTable) + ` (version bigint primary key, dirty boolean not null)`
|
||||
@@ -469,7 +469,7 @@ func (p *Postgres) EnsureVersionTable(ctx context.Context) (err error) {
|
||||
if wpErr := rollback(); wpErr != nil {
|
||||
err = multierror.Append(err, wpErr)
|
||||
}
|
||||
return errors.Wrap(err, op)
|
||||
return errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -15,20 +15,20 @@ func MigrateStore(ctx context.Context, dialect string, url string, opt ...Option
|
||||
|
||||
d, err := sql.Open(dialect, url)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, op)
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
sMan, err := NewManager(ctx, dialect, d, opt...)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, op)
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
st, err := sMan.CurrentState(ctx)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, op)
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
if st.Dirty {
|
||||
return false, errors.New(errors.MigrationIntegrity, op, "db marked dirty")
|
||||
return false, errors.New(ctx, errors.MigrationIntegrity, op, "db marked dirty")
|
||||
}
|
||||
|
||||
if st.InitializationStarted && st.DatabaseSchemaVersion == st.BinarySchemaVersion {
|
||||
@@ -36,7 +36,7 @@ func MigrateStore(ctx context.Context, dialect string, url string, opt ...Option
|
||||
}
|
||||
|
||||
if err := sMan.RollForward(ctx); err != nil {
|
||||
return false, errors.Wrap(err, op)
|
||||
return false, errors.Wrap(ctx, err, op)
|
||||
}
|
||||
|
||||
return true, nil
|
||||
|
||||
Reference in new issue
Block a user