Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Add seed data to simulate a push event

天舟ab9920ebbea5
diff --git a/backend/server/webhook.go b/backend/server/webhook.go
index 11dd6df801..31f1140743 100644
--- a/backend/server/webhook.go
+++ b/backend/server/webhook.go
@@ -156,11 +156,11 @@ func (s *Server) registerWebhookRoutes(g *echo.Group) {
stage := &api.StageCreate{
EnvironmentId: database.Instance.EnvironmentId,
TaskList: []api.TaskCreate{*task},
- Name: fmt.Sprintf("Update %s schema", database.Name),
+ Name: database.Instance.Environment.Name,
}
pipeline := &api.PipelineCreate{
StageList: []api.StageCreate{*stage},
- Name: commit.Title,
+ Name: fmt.Sprintf("Pipeline - %s", commit.Title),
}
issueCreate := &api.IssueCreate{
ProjectId: database.ProjectId,
diff --git a/backend/store/seed/0090_pipeline.sql b/backend/store/seed/0090_pipeline.sql
index 691d79465c..48ef38260a 100644
--- a/backend/store/seed/0090_pipeline.sql
+++ b/backend/store/seed/0090_pipeline.sql
@@ -50,4 +50,22 @@ VALUES
1003,
'Pipeline - Create table ''tbl1''',
'OPEN'
+ );
+
+-- A pipeline simulating webhook push event
+INSERT INTO
+ pipeline (
+ id,
+ creator_id,
+ updater_id,
+ name,
+ `status`
+ )
+VALUES
+ (
+ 9004,
+ 1,
+ 1,
+ 'Pipeline - Create todo table to staging db1',
+ 'OPEN'
);
\ No newline at end of file
diff --git a/backend/store/seed/0100_stage.sql b/backend/store/seed/0100_stage.sql
index 2a6be4544d..aba2386070 100644
--- a/backend/store/seed/0100_stage.sql
+++ b/backend/store/seed/0100_stage.sql
@@ -132,4 +132,24 @@ VALUES
9003,
5002,
'Integration'
+ );
+
+-- Stage for Pipeline 9004 simulating webhook push event
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10008,
+ 1,
+ 1,
+ 9004,
+ 5003,
+ 'Staging'
);
\ No newline at end of file
diff --git a/backend/store/seed/0110_task.sql b/backend/store/seed/0110_task.sql
index a37287de5b..3c4b3cf11c 100644
--- a/backend/store/seed/0110_task.sql
+++ b/backend/store/seed/0110_task.sql
@@ -208,4 +208,34 @@ VALUES
'bb.task.database.schema.update',
'PENDING',
'{"statement":"CREATE TABLE integrationdb1.tbl1 (name TEXT);", "rollbackStatement":"DROP TABLE integrationdb1.tbl1;"}'
+ );
+
+-- Task for stage 10008 "Staging" to update database 7010 'stagingdb1' to simulate webhook push event
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11008,
+ 1,
+ 1,
+ 9004,
+ 10008,
+ 6003,
+ 7010,
+ 'create todo table',
+ 'bb.task.database.schema.update',
+ 'PENDING',
+ '{"statement":"CREATE TABLE todo (\n id INTEGER PRIMARY KEY AUTO_INCREMENT,\n title TEXT\n)\n","pushEvent":{"ref":"refs/heads/master","repoId":"7","repoUrl":"http://gitlab.bytebase.com/bytebase-test/project1","repoFullPath":"bytebase-test/project1","authorName":"tianzhou","fileCommit":{"id":"e3b3f33a455a7e3cd999b44fa9cb8ddb633e1d29","title":"Create todo table to staging db1","message":"Create todo table to staging db1","createdTs":1624006500,"url":"http://gitlab.bytebase.com/bytebase-test/project1/-/commit/e3b3f33a455a7e3cd999b44fa9cb8ddb633e1d29","authorName":"tianzhou","added":"bytebase/20210618164921_stagingdb1_create_todo_table.sql"}}}'
);
\ No newline at end of file
diff --git a/backend/store/seed/0130_issue.sql b/backend/store/seed/0130_issue.sql
index 9d79108746..800d5168ae 100644
--- a/backend/store/seed/0130_issue.sql
+++ b/backend/store/seed/0130_issue.sql
@@ -86,4 +86,34 @@ VALUES
'Create tbl1.',
1001,
'1001,1002,1003,1004'
+ );
+
+-- Issue for simulating webhook push event
+INSERT INTO
+ issue (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ pipeline_id,
+ name,
+ `status`,
+ `type`,
+ description,
+ assignee_id,
+ subscriber_id_list
+ )
+VALUES
+ (
+ 13004,
+ 1,
+ 1,
+ 3001,
+ 9004,
+ 'Create todo table to stagingdb1',
+ 'OPEN',
+ 'bb.issue.database.schema.update',
+ 'Create todo table to stagingdb1',
+ 1,
+ ''
);
\ No newline at end of file