Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
42 lines (33 loc) · 1.31 KB

File metadata and controls

42 lines (33 loc) · 1.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package server
import (
"context"
"encoding/json"
"sync/atomic"
"github.com/pkg/errors"
"github.com/bytebase/bytebase/api"
)
// NewSchemaUpdateTaskExecutor creates a schema update (DDL) task executor.
func NewSchemaUpdateTaskExecutor() TaskExecutor {
return &SchemaUpdateTaskExecutor{}
}
// SchemaUpdateTaskExecutor is the schema update (DDL) task executor.
type SchemaUpdateTaskExecutor struct {
completed int32
}
// RunOnce will run the schema update (DDL) task executor once.
func (exec *SchemaUpdateTaskExecutor) RunOnce(ctx context.Context, server *Server, task *api.Task) (terminated bool, result *api.TaskRunResultPayload, err error) {
defer atomic.StoreInt32(&exec.completed, 1)
payload := &api.TaskDatabaseSchemaUpdatePayload{}
if err := json.Unmarshal([]byte(task.Payload), payload); err != nil {
return true, nil, errors.Wrap(err, "invalid database schema update payload")
}
return runMigration(ctx, server, task, payload.MigrationType, payload.Statement, payload.SchemaVersion, payload.VCSPushEvent)
}
// IsCompleted tells the scheduler if the task execution has completed.
func (exec *SchemaUpdateTaskExecutor) IsCompleted() bool {
return atomic.LoadInt32(&exec.completed) == 1
}
// GetProgress returns the task progress.
func (*SchemaUpdateTaskExecutor) GetProgress() api.Progress {
return api.Progress{}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.