Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(gh-ost): demo seed data (#1114)
p0nyc25702aecab3
diff --git a/api/task_dag.go b/api/task_dag.goindex 2b03c4d2a8..2ae34db682 100644--- a/api/task_dag.go+++ b/api/task_dag.go@@ -1,7 +1,7 @@package api// TaskDAG describes task dependency relationship.-// FromTaskID is blocked by ToTaskID+// FromTaskID blocks ToTaskID// It's rather DAGEdge than DAGtype TaskDAG struct {ID int@@ -25,5 +25,5 @@ type TaskDAGCreate struct {// TaskDAGFind is the API message to find TaskDAG.type TaskDAGFind struct {- FromTaskID int+ ToTaskID int}diff --git a/server/task.go b/server/task.goindex c957ff580f..0a6c309d1e 100644--- a/server/task.go+++ b/server/task.go@@ -459,12 +459,12 @@ func (s *Server) composeTaskRelationship(ctx context.Context, raw *api.TaskRaw)}blockedBy := []string{}- taskDAGList, err := s.store.FindTaskDAGList(ctx, &api.TaskDAGFind{FromTaskID: raw.ID})+ taskDAGList, err := s.store.FindTaskDAGList(ctx, &api.TaskDAGFind{ToTaskID: raw.ID})if err != nil {return nil, err}for _, taskDAG := range taskDAGList {- blockedBy = append(blockedBy, strconv.Itoa(taskDAG.ToTaskID))+ blockedBy = append(blockedBy, strconv.Itoa(taskDAG.FromTaskID))}task.BlockedBy = blockedBydiff --git a/store/demo/dev/10090__pipeline.sql b/store/demo/dev/10090__pipeline.sqlindex 1cab63b163..68be15a831 100644--- a/store/demo/dev/10090__pipeline.sql+++ b/store/demo/dev/10090__pipeline.sql@@ -188,4 +188,26 @@ VALUES'OPEN');-ALTER SEQUENCE pipeline_id_seq RESTART WITH 9010;+-- Pipeline for task dependency+INSERT INTO+ pipeline (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ name,+ status+ )+VALUES+ (+ 9010,+ 1,+ 1624879944,+ 1,+ 1624879944,+ 'Pipeline - Task Dependency',+ 'OPEN'+ );++ALTER SEQUENCE pipeline_id_seq RESTART WITH 9011;diff --git a/store/demo/dev/10100__stage.sql b/store/demo/dev/10100__stage.sqlindex 7cb971f27a..f5cade4cbf 100644--- a/store/demo/dev/10100__stage.sql+++ b/store/demo/dev/10100__stage.sql@@ -363,4 +363,28 @@ VALUES'Prod');-ALTER SEQUENCE stage_id_seq RESTART WITH 10017;+-- Stage for task dependency+INSERT INTO+ stage (+ id,+ creator_id,+ created_ts,+ updater_id,+ updated_ts,+ pipeline_id,+ environment_id,+ name+ )+VALUES+ (+ 10017,+ 1,+ 1624865387,+ 1,+ 1624865387,+ 9010,+ 5001,+ 'Dev'+ );++ALTER SEQUENCE stage_id_seq RESTART WITH 10018;diff --git a/store/demo/dev/10110__task.sql b/store/demo/dev/10110__task.sqlindex c0dde9ca79..635d737c73 100644--- a/store/demo/dev/10110__task.sql+++ b/store/demo/dev/10110__task.sql@@ -518,4 +518,94 @@ VALUES'{"migrationType":"MIGRATE","statement":"CREATE TABLE testdb_prod.tbl2 (name TEXT);"}');-ALTER SEQUENCE task_id_seq RESTART WITH 11017;+-- Task for task dependency++INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11017,+ 1,+ 1,+ 9010,+ 10017,+ 6001,+ 7002,+ 'Update testdb_dev gh-ost sync',+ 'bb.task.database.schema.update.ghost.sync',+ 'PENDING_APPROVAL',+ '{"statement":"ALTER TABLE tbl1 ENGINE=InnoDB;"}'+ );++INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11018,+ 1,+ 1,+ 9010,+ 10017,+ 6001,+ 7002,+ 'Update testdb_dev gh-ost cutover',+ 'bb.task.database.schema.update.ghost.cutover',+ 'PENDING_APPROVAL',+ '{}'+ );++INSERT INTO+ task (+ id,+ creator_id,+ updater_id,+ pipeline_id,+ stage_id,+ instance_id,+ database_id,+ name,+ type,+ status,+ payload+ )+VALUES+ (+ 11019,+ 1,+ 1,+ 9010,+ 10017,+ 6001,+ 7002,+ 'Update testdb_dev gh-ost drop original table',+ 'bb.task.database.schema.update.ghost.drop-original-table',+ 'PENDING_APPROVAL',+ '{"databaseName":"testdb_prod","tableName":"_tbl1_del"}'+ );+++ALTER SEQUENCE task_id_seq RESTART WITH 11020;diff --git a/store/demo/dev/10111__task_dag.sql b/store/demo/dev/10111__task_dag.sqlnew file mode 100644index 0000000000..8a6f465d59--- /dev/null+++ b/store/demo/dev/10111__task_dag.sql@@ -0,0 +1,29 @@+-- task_dag for task dependency++INSERT INTO+ task_dag (+ id,+ from_task_id,+ to_task_id+ )+VALUES+ (+ 11101,+ 11017,+ 11018+ );++INSERT INTO+ task_dag (+ id,+ from_task_id,+ to_task_id+ )+VALUES+ (+ 11102,+ 11018,+ 11019+ );++ALTER SEQUENCE task_dag_id_seq RESTART WITH 11103;diff --git a/store/demo/dev/10130__issue.sql b/store/demo/dev/10130__issue.sqlindex d15b494c2d..ff70592ef2 100644--- a/store/demo/dev/10130__issue.sql+++ b/store/demo/dev/10130__issue.sql@@ -274,4 +274,32 @@ VALUES102);-ALTER SEQUENCE issue_id_seq RESTART WITH 13010;+-- Issue for task dependency+INSERT INTO+ issue (+ id,+ creator_id,+ updater_id,+ project_id,+ pipeline_id,+ name,+ status,+ type,+ description,+ assignee_id+ )+VALUES+ (+ 13010,+ 1,+ 1,+ 3001,+ 9010,+ 'Hello task dependency!',+ 'OPEN',+ 'bb.issue.database.schema.update',+ 'This issue is to demonstrate task dependency.',+ 101+ );++ALTER SEQUENCE issue_id_seq RESTART WITH 13011;diff --git a/store/task_dag.go b/store/task_dag.goindex 55c3669457..9333f134ff 100644--- a/store/task_dag.go+++ b/store/task_dag.go@@ -128,8 +128,8 @@ func findTaskDAGRawListImpl(ctx context.Context, tx *sql.Tx, find *api.TaskDAGFito_task_id,payloadFROM task_dag- WHERE from_task_id = $1- `, find.FromTaskID)+ WHERE to_task_id = $1+ `, find.ToTaskID)if err != nil {return nil, FormatError(err)}