diff --git a/go/cmd/dolt/commands/ci/init.go b/go/cmd/dolt/commands/ci/init.go index de83d5b815..f357995602 100644 --- a/go/cmd/dolt/commands/ci/init.go +++ b/go/cmd/dolt/commands/ci/init.go @@ -21,7 +21,6 @@ import ( "github.com/dolthub/dolt/go/cmd/dolt/cli" "github.com/dolthub/dolt/go/cmd/dolt/commands" "github.com/dolthub/dolt/go/cmd/dolt/errhand" - "github.com/dolthub/dolt/go/libraries/doltcore/doltdb" "github.com/dolthub/dolt/go/libraries/doltcore/env" "github.com/dolthub/dolt/go/libraries/doltcore/env/actions/dolt_ci" "github.com/dolthub/dolt/go/libraries/doltcore/sqle" @@ -80,8 +79,7 @@ func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, d return 1 } - newCtx := doltdb.ContextWithDoltCICreateBypassKey(ctx) - queryist, sqlCtx, closeFunc, err := cliCtx.QueryEngine(newCtx) + queryist, sqlCtx, closeFunc, err := cliCtx.QueryEngine(ctx) if err != nil { return commands.HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage) } diff --git a/go/libraries/doltcore/doltdb/system_table.go b/go/libraries/doltcore/doltdb/system_table.go index 29ded87ee7..52a25bf0d2 100644 --- a/go/libraries/doltcore/doltdb/system_table.go +++ b/go/libraries/doltcore/doltdb/system_table.go @@ -20,6 +20,8 @@ import ( "sort" "strings" + "github.com/dolthub/go-mysql-server/sql" + "github.com/dolthub/dolt/go/libraries/doltcore/schema" "github.com/dolthub/dolt/go/libraries/doltcore/schema/typeinfo" "github.com/dolthub/dolt/go/libraries/utils/funcitr" @@ -61,10 +63,13 @@ func init() { DocsSchema = schema.MustSchemaFromCols(doltDocsColumns) } -func ContextWithDoltCICreateBypassKey(ctx context.Context) context.Context { - return context.WithValue(ctx, doltCICtxKey, doltCICtxValueAllow) +// ContextWithDoltCICreateBypassKey returns the sql.Context with a key that will +// allow dolt_ci tables to be created +func ContextWithDoltCICreateBypassKey(ctx *sql.Context) *sql.Context { + return ctx.WithContext(context.WithValue(ctx, doltCICtxKey, doltCICtxValueAllow)) } +// IsDoltCICreateAllowed checks whether dolt_ci tables can be created func IsDoltCICreateAllowed(ctx context.Context) bool { if v := ctx.Value(doltCICtxKey); v != nil { if v == doltCICtxValueAllow { diff --git a/go/libraries/doltcore/env/actions/dolt_ci/schema.go b/go/libraries/doltcore/env/actions/dolt_ci/schema.go index 004411c01a..e78d5d80ce 100644 --- a/go/libraries/doltcore/env/actions/dolt_ci/schema.go +++ b/go/libraries/doltcore/env/actions/dolt_ci/schema.go @@ -184,14 +184,16 @@ func CreateDoltCITables(ctx *sql.Context, db sqle.Database, queryFunc queryFunc, deleteAllFromWorkflowsTableQuery(), // as last step run delete to create resolve all indexes/fks } + newCtx := doltdb.ContextWithDoltCICreateBypassKey(ctx) + for _, query := range orderedCreateTableQueries { - err := SqlWriteQuery(ctx, queryFunc, query) + err := SqlWriteQuery(newCtx, queryFunc, query) if err != nil { return err } } - return commitCIInit(ctx, queryFunc, commiterName, commiterEmail) + return commitCIInit(newCtx, queryFunc, commiterName, commiterEmail) } func createWorkflowsTableQuery() string {