Skip to content

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

Add a multi-stage UI based create table pipeline

天舟b4253b9e0d26
diff --git a/store/seed/test/10090__pipeline.sql b/store/seed/test/10090__pipeline.sql
index 3b919874e9..fec2db9e32 100644
--- a/store/seed/test/10090__pipeline.sql
+++ b/store/seed/test/10090__pipeline.sql
@@ -164,4 +164,26 @@ VALUES
1624869944,
'Pipeline - Add created_at column to user,post,comment table for dev environment',
'OPEN'
+ );
+
+-- Pipeline for multi-stage create table UI workflow
+INSERT INTO
+ pipeline (
+ id,
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ name,
+ `status`
+ )
+VALUES
+ (
+ 9009,
+ 103,
+ 1624879944,
+ 103,
+ 1624879944,
+ 'Pipeline - Create a new table tbl2',
+ 'OPEN'
);
\ No newline at end of file
diff --git a/store/seed/test/10100__stage.sql b/store/seed/test/10100__stage.sql
index 89803c5975..c5b5a57c24 100644
--- a/store/seed/test/10100__stage.sql
+++ b/store/seed/test/10100__stage.sql
@@ -268,4 +268,97 @@ VALUES
9008,
5001,
'Dev'
+ );
+
+-- Stage for Pipeline 9009 multi-stage create table UI workflow
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10013,
+ 103,
+ 1624879944,
+ 103,
+ 1624879944,
+ 9009,
+ 5001,
+ 'Dev'
+ );
+
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10014,
+ 103,
+ 1624879944,
+ 103,
+ 1624879944,
+ 9009,
+ 5002,
+ 'Integration'
+ );
+
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10015,
+ 103,
+ 1624879944,
+ 103,
+ 1624879944,
+ 9009,
+ 5003,
+ 'Staging'
+ );
+
+INSERT INTO
+ stage (
+ id,
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ pipeline_id,
+ environment_id,
+ name
+ )
+VALUES
+ (
+ 10016,
+ 103,
+ 1624879944,
+ 103,
+ 1624879944,
+ 9009,
+ 5004,
+ 'Prod'
);
\ No newline at end of file
diff --git a/store/seed/test/10110__task.sql b/store/seed/test/10110__task.sql
index 4603209ff5..84f5dd90ad 100644
--- a/store/seed/test/10110__task.sql
+++ b/store/seed/test/10110__task.sql
@@ -394,4 +394,126 @@ VALUES
'bb.task.database.schema.update',
'FAILED',
'{"statement":"ALTER TABLE `user` ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE post ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE comment ADD COLUMN `created_at` DATETIME NOT NULL;\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repoId":"13","repoUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repoFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"171ceaf7659ceb8e495aa3ef356ec686656f9dc0","title":"Add created_at column to user,post,comment table for dev environment","message":"Add created_at column to user,post,comment table for dev environment","createdTs":1624869938,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/171ceaf7659ceb8e495aa3ef356ec686656f9dc0","authorName":"tianzhou","added":"bytebase/dev/202106280100__blog__add_created_at_column.sql"}}}'
+ );
+
+-- Task for Pipeline 9009 multi-stage create table UI workflow
+-- Task for stage 10013 "Dev" to create table in database 7002 'testdb_dev'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11013,
+ 103,
+ 103,
+ 9009,
+ 10013,
+ 6001,
+ 7002,
+ 'Update testdb_dev',
+ 'bb.task.database.schema.update',
+ 'DONE',
+ '{"statement":"CREATE TABLE testdb_dev.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_dev.tbl2;"}'
+ );
+
+-- Task for stage 10014 "Integration" to create table in database 7006 'testdb_integration'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11014,
+ 103,
+ 103,
+ 9009,
+ 10014,
+ 6002,
+ 7006,
+ 'Update testdb_integration',
+ 'bb.task.database.schema.update',
+ 'DONE',
+ '{"statement":"CREATE TABLE testdb_integration.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_integration.tbl2;"}'
+ );
+
+
+-- Task for stage 10015 "Integration" to create table in database 7010 'testdb_staging'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11015,
+ 103,
+ 103,
+ 9009,
+ 10015,
+ 6003,
+ 7010,
+ 'Update testdb_staging',
+ 'bb.task.database.schema.update',
+ 'PENDING_APPROVAL',
+ '{"statement":"CREATE TABLE testdb_staging.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_staging.tbl2;"}'
+ );
+
+-- Task for stage 10016 "prod" to create table in database 7014 'testdb_prod'
+INSERT INTO
+ task (
+ id,
+ creator_id,
+ updater_id,
+ pipeline_id,
+ stage_id,
+ instance_id,
+ database_id,
+ name,
+ `type`,
+ `status`,
+ payload
+ )
+VALUES
+ (
+ 11016,
+ 103,
+ 103,
+ 9009,
+ 10016,
+ 6004,
+ 7014,
+ 'Update testdb_prod',
+ 'bb.task.database.schema.update',
+ 'PENDING_APPROVAL',
+ '{"statement":"CREATE TABLE testdb_prod.tbl2 (name TEXT);", "rollbackStatement":"DROP TABLE testdb_prod.tbl2;"}'
);
\ No newline at end of file
diff --git a/store/seed/test/10120__task_run.sql b/store/seed/test/10120__task_run.sql
index 2abefce08f..ebf36f25ad 100644
--- a/store/seed/test/10120__task_run.sql
+++ b/store/seed/test/10120__task_run.sql
@@ -216,4 +216,60 @@ VALUES
'bb.task.database.schema.update',
'database ''blog'' has already applied version 202106280100',
'{"statement":"ALTER TABLE `user` ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE post ADD COLUMN `created_at` DATETIME NOT NULL;\n\nALTER TABLE comment ADD COLUMN `created_at` DATETIME NOT NULL;\n","pushEvent":{"vcsType":"GITLAB_SELF_HOST","baseDir":"bytebase","ref":"refs/heads/master","repoId":"13","repoUrl":"http://gitlab.bytebase.com/bytebase-demo/blog","repoFullPath":"bytebase-demo/blog","authorName":"tianzhou","fileCommit":{"id":"171ceaf7659ceb8e495aa3ef356ec686656f9dc0","title":"Add created_at column to user,post,comment table for dev environment","message":"Add created_at column to user,post,comment table for dev environment","createdTs":1624869938,"url":"http://gitlab.bytebase.com/bytebase-demo/blog/-/commit/171ceaf7659ceb8e495aa3ef356ec686656f9dc0","authorName":"tianzhou","added":"bytebase/dev/202106280100__blog__add_created_at_column.sql"}}}'
+ );
+
+-- Successful task run for task 10013 create table
+INSERT INTO
+ task_run (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ task_id,
+ name,
+ `status`,
+ `type`,
+ comment,
+ payload
+ )
+VALUES
+ (
+ 102,
+ 1624879944,
+ 102,
+ 1624879944,
+ 11013,
+ 'Update testdb_dev task run',
+ 'DONE',
+ 'bb.task.database.schema.update',
+ 'Applied migration version 20210830011437.11013 to database "testdb_dev"',
+ '{"statement":"CREATE TABLE testdb_dev.tbl2 (name TEXT)"}'
+ );
+
+-- Successful task run for task 10014 create table
+INSERT INTO
+ task_run (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ task_id,
+ name,
+ `status`,
+ `type`,
+ comment,
+ payload
+ )
+VALUES
+ (
+ 102,
+ 1624879944,
+ 102,
+ 1624879944,
+ 11014,
+ 'Update testdb_integration task run',
+ 'DONE',
+ 'bb.task.database.schema.update',
+ 'Applied migration version 20210830020000.11014 to database "testdb_integration"',
+ '{"statement":"CREATE TABLE testdb_integration.tbl2 (name TEXT)"}'
);
\ No newline at end of file
diff --git a/store/seed/test/10130__issue.sql b/store/seed/test/10130__issue.sql
index 01cd634b9b..ce67349e06 100644
--- a/store/seed/test/10130__issue.sql
+++ b/store/seed/test/10130__issue.sql
@@ -244,4 +244,32 @@ VALUES
'bb.issue.database.schema.update',
'Add created_at column to user,post,comment table for dev environment',
1
- );
\ No newline at end of file
+ );
+
+-- Issue for multi-stage create table UI workflow
+INSERT INTO
+ issue (
+ id,
+ creator_id,
+ updater_id,
+ project_id,
+ pipeline_id,
+ name,
+ `status`,
+ `type`,
+ description,
+ assignee_id
+ )
+VALUES
+ (
+ 13009,
+ 103,
+ 103,
+ 3001,
+ 9009,
+ 'Create a new table ''tabl2'' using multi-stage SQL review workflow',
+ 'OPEN',
+ 'bb.issue.general',
+ 'Create tbl2 using multi-stage SQL review workflow',
+ 102
+ );
diff --git a/store/seed/test/10131__issue_subscriber.sql b/store/seed/test/10131__issue_subscriber.sql
index 364c9b5ee4..24d26bcfa1 100644
--- a/store/seed/test/10131__issue_subscriber.sql
+++ b/store/seed/test/10131__issue_subscriber.sql
@@ -99,4 +99,20 @@ VALUES
INSERT INTO
issue_subscriber (issue_id, subscriber_id)
VALUES
- (13007, 103);
\ No newline at end of file
+ (13007, 103);
+
+-- Subscriber for issue 13009
+INSERT INTO
+ issue_subscriber (issue_id, subscriber_id)
+VALUES
+ (13009, 101);
+
+INSERT INTO
+ issue_subscriber (issue_id, subscriber_id)
+VALUES
+ (13009, 102);
+
+INSERT INTO
+ issue_subscriber (issue_id, subscriber_id)
+VALUES
+ (13009, 103);
\ No newline at end of file
diff --git a/store/seed/test/10140__activity.sql b/store/seed/test/10140__activity.sql
index 1e4ad12ff4..9c6536db97 100644
--- a/store/seed/test/10140__activity.sql
+++ b/store/seed/test/10140__activity.sql
@@ -797,4 +797,130 @@ VALUES
'ERROR',
'database ''blog'' has already applied version 202106280100',
'{"taskId":11012,"oldStatus":"RUNNING","newStatus":"FAILED"}'
+ );
+
+-- Activity for issue 13009
+INSERT INTO
+ activity (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ container_id,
+ `type`,
+ `level`,
+ COMMENT,
+ payload
+ )
+VALUES
+ (
+ 103,
+ 1624879944,
+ 103,
+ 1624879944,
+ 13009,
+ 'bb.issue.create',
+ 'INFO',
+ '',
+ '{"issueName":"Create a new table ''tabl2'' using multi-stage SQL review workflow"}'
+ );
+
+INSERT INTO
+ activity (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ container_id,
+ `type`,
+ `level`,
+ COMMENT,
+ payload
+ )
+VALUES
+ (
+ 102,
+ 1624879944,
+ 102,
+ 1624879944,
+ 13009,
+ 'bb.pipeline.task.status.update',
+ 'INFO',
+ '',
+ '{"taskId":11015,"oldStatus":"PENDING","newStatus":"RUNNING","issueName":"Create a new table ''tabl2'' using multi-stage SQL review workflow","taskName":"Update testdb_dev"}'
+ );
+
+INSERT INTO
+ activity (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ container_id,
+ `type`,
+ `level`,
+ COMMENT,
+ payload
+ )
+VALUES
+ (
+ 102,
+ 1624879944,
+ 102,
+ 1624879944,
+ 13009,
+ 'bb.pipeline.task.status.update',
+ 'INFO',
+ 'Applied migration version 20210830011437.11013 to database "testdb_dev"',
+ '{"taskId":11015,"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create a new table ''tabl2'' using multi-stage SQL review workflow","taskName":"Update testdb_dev"}'
+ );
+
+INSERT INTO
+ activity (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ container_id,
+ `type`,
+ `level`,
+ COMMENT,
+ payload
+ )
+VALUES
+ (
+ 102,
+ 1624879944,
+ 102,
+ 1624879944,
+ 13009,
+ 'bb.pipeline.task.status.update',
+ 'INFO',
+ '',
+ '{"taskId":11016,"oldStatus":"PENDING","newStatus":"RUNNING","issueName":"Create a new table ''tabl2'' using multi-stage SQL review workflow","taskName":"Update testdb_dev"}'
+ );
+
+INSERT INTO
+ activity (
+ creator_id,
+ created_ts,
+ updater_id,
+ updated_ts,
+ container_id,
+ `type`,
+ `level`,
+ COMMENT,
+ payload
+ )
+VALUES
+ (
+ 102,
+ 1624879944,
+ 102,
+ 1624879944,
+ 13009,
+ 'bb.pipeline.task.status.update',
+ 'INFO',
+ 'Applied migration version 20210830020000.11014 to database "testdb_integration"',
+ '{"taskId":11016,"oldStatus":"RUNNING","newStatus":"DONE","issueName":"Create a new table ''tabl2'' using multi-stage SQL review workflow","taskName":"Update testdb_integration"}'
);
\ No newline at end of file