Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Support generating multi stage issue
天舟e4045ad00132
diff --git a/backend/api/issue.go b/backend/api/issue.goindex e5cfe1db31..a538eae61e 100644--- a/backend/api/issue.go+++ b/backend/api/issue.go@@ -109,14 +109,12 @@ type IssueCreate struct {Pipeline PipelineCreate `jsonapi:"attr,pipeline"`// Domain specific fields- Name string `jsonapi:"attr,name"`- Type IssueType `jsonapi:"attr,type"`- Description string `jsonapi:"attr,description"`- AssigneeId int `jsonapi:"attr,assigneeId"`- SubscriberIdList []int `jsonapi:"attr,subscriberIdList"`- Statement string `jsonapi:"attr,statement"`- RollbackStatement string `jsonapi:"attr,rollbackStatement"`- Payload IssuePayload `jsonapi:"attr,payload"`+ Name string `jsonapi:"attr,name"`+ Type IssueType `jsonapi:"attr,type"`+ Description string `jsonapi:"attr,description"`+ AssigneeId int `jsonapi:"attr,assigneeId"`+ SubscriberIdList []int `jsonapi:"attr,subscriberIdList"`+ Payload IssuePayload `jsonapi:"attr,payload"`}type IssueFind struct {diff --git a/backend/api/task.go b/backend/api/task.goindex de58ae53e6..0dccead313 100644--- a/backend/api/task.go+++ b/backend/api/task.go@@ -89,10 +89,13 @@ type TaskCreate struct {DatabaseId int `jsonapi:"attr,databaseId"`// Domain specific fields- Name string `jsonapi:"attr,name"`- Status TaskStatus `jsonapi:"attr,status"`- Type TaskType `jsonapi:"attr,type"`- Payload string `jsonapi:"attr,payload"`+ Name string `jsonapi:"attr,name"`+ Status TaskStatus `jsonapi:"attr,status"`+ Type TaskType `jsonapi:"attr,type"`+ Statement string `jsonapi:"attr,statement"`+ RollbackStatement string `jsonapi:"attr,rollbackStatement"`+ // Payload is dirived from Statement, RollbackStatement+ Payload string}type TaskFind struct {diff --git a/backend/server/issue.go b/backend/server/issue.goindex 358a32e707..6d94344abd 100644--- a/backend/server/issue.go+++ b/backend/server/issue.go@@ -41,11 +41,11 @@ func (s *Server) registerIssueRoutes(g *echo.Group) {taskCreate.StageId = createdStage.IDif taskCreate.Type == api.TaskDatabaseSchemaUpdate {payload := api.TaskDatabaseSchemaUpdatePayload{}- if issueCreate.Statement != "" {- payload.Statement = issueCreate.Statement+ if taskCreate.Statement != "" {+ payload.Statement = taskCreate.Statement}- if issueCreate.RollbackStatement != "" {- payload.RollbackStatement = issueCreate.RollbackStatement+ if taskCreate.RollbackStatement != "" {+ payload.RollbackStatement = taskCreate.RollbackStatement}bytes, err := json.Marshal(payload)if err != nil {diff --git a/frontend/src/components/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm.vueindex 9e1e758016..721fed4632 100644--- a/frontend/src/components/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm.vue@@ -286,7 +286,34 @@ export default {return state.selectedDatabaseIdForEnvironment.size > 0;});- const generateMultDb = () => {};+ const generateMultDb = () => {+ const databaseIdList: DatabaseId[] = [];+ for (var i = 0; i < environmentList.value.length; i++) {+ if (+ state.selectedDatabaseIdForEnvironment.get(+ environmentList.value[i].id+ )+ ) {+ databaseIdList.push(+ state.selectedDatabaseIdForEnvironment.get(+ environmentList.value[i].id+ )!+ );+ }+ }+ router.push({+ name: "workspace.issue.detail",+ params: {+ issueSlug: "new",+ },+ query: {+ template: "bb.issue.database.schema.update",+ name: `Alter schema`,+ project: props.projectId,+ databaseList: databaseIdList.join(","),+ },+ });+ };const selectDatabaseId = (databaseId: DatabaseId) => {emit("dismiss");diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.tsindex f3af4ff589..3de76dda78 100644--- a/frontend/src/types/issue.ts+++ b/frontend/src/types/issue.ts@@ -57,8 +57,6 @@ export type IssueCreate = {type: IssueType;description: string;assigneeId?: PrincipalId;- statement?: string;- rollbackStatement?: string;payload: IssuePayload;};diff --git a/frontend/src/types/pipeline.ts b/frontend/src/types/pipeline.tsindex 805836aa70..1721df8c3c 100644--- a/frontend/src/types/pipeline.ts+++ b/frontend/src/types/pipeline.ts@@ -235,6 +235,8 @@ export type TaskCreate = {type: TaskType;instanceId: InstanceId;databaseId?: DatabaseId;+ statement: string;+ rollbackStatement: string;};export type TaskStatusPatch = {diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.tsindex 898a829a15..96dc7e3538 100644--- a/frontend/src/utils/pipeline.ts+++ b/frontend/src/utils/pipeline.ts@@ -10,6 +10,7 @@ import {UNKNOWN_ID,unknown,TaskId,+ PipelineCreate,} from "../types";export type PipelineType =@@ -18,7 +19,9 @@ export type PipelineType =| "MULTI_SINGLE_TASK_STAGE"| "MULTI_STAGE";-export function pipelineType(pipeline: Pipeline): PipelineType {+export function pipelineType(+ pipeline: Pipeline | PipelineCreate+): PipelineType {if (pipeline.stageList.length == 0) {return "NO_PIPELINE";} else if (pipeline.stageList.length == 1) {diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vueindex 21b7ccc983..a513e29bbf 100644--- a/frontend/src/views/IssueDetail.vue+++ b/frontend/src/views/IssueDetail.vue@@ -80,11 +80,15 @@"><PipelineSimpleFlow+ :create="state.create":pipeline="issue.pipeline":selectedStage="selectedStage"@select-stage-id="selectStageId"/>- <div class="px-4 py-4 md:flex md:flex-col border-b">+ <div+ v-if="!state.create"+ class="px-4 py-4 md:flex md:flex-col border-b"+ ><IssueStagePanel :stage="selectedStage" /></div></template>@@ -232,6 +236,8 @@ import {IssueStatusPatch,Task,DatabaseSchemaUpdateTaskPayload,+ StageCreate,+ TaskCreate,} from "../types";import {defaulTemplate,@@ -367,13 +373,6 @@ export default {newIssue.description = router.currentRoute.value.query.description as string;}- if (router.currentRoute.value.query.sql) {- newIssue.statement = router.currentRoute.value.query.sql as string;- }- if (router.currentRoute.value.query.rollbacksql) {- newIssue.rollbackStatement = router.currentRoute.value.query- .rollbacksql as string;- }if (router.currentRoute.value.query.assignee) {newIssue.assigneeId = parseInt(router.currentRoute.value.query.assignee as string@@ -463,13 +462,15 @@ export default {}};- // We only allow updating sql/rollback upon issue creation.+ // We only allow updating statement/rollbackStatement upon issue creation.const updateStatement = (newStatement: string) => {- state.newIssue!.statement = newStatement;+ const stage = selectedStage.value as StageCreate;+ stage.taskList[0].statement = newStatement;};const updateRollbackStatement = (newStatement: string) => {- state.newIssue!.rollbackStatement = newStatement;+ const stage = selectedStage.value as StageCreate;+ stage.taskList[0].rollbackStatement = newStatement;};const updateDescription = (@@ -605,23 +606,30 @@ export default {};const currentPipelineType = computed((): PipelineType => {- return pipelineType((issue.value as Issue).pipeline);+ return pipelineType(issue.value.pipeline);});console.debug(currentPipelineType.value);- const selectedStage = computed((): Stage => {+ const selectedStage = computed((): Stage | StageCreate => {const stageSlug = router.currentRoute.value.query.stage as string;if (stageSlug) {const index = indexFromSlug(stageSlug);- return (issue.value as Issue).pipeline.stageList[index];+ return issue.value.pipeline.stageList[index];+ }++ if (state.create) {+ return issue.value.pipeline.stageList[0];}return activeStage((issue.value as Issue).pipeline);});const selectStageId = (stageId: StageId) => {const stageList = (issue.value as Issue).pipeline.stageList;- const index = stageList.findIndex((item) => {+ const index = stageList.findIndex((item, index) => {+ if (state.create) {+ return index == stageId;+ }return item.id == stageId;});router.replace({@@ -633,27 +641,21 @@ export default {});};- const selectedTask = computed((): Task => {- const stage = selectedStage.value;- return stage.taskList[0];- });-const selectedStatement = computed((): string => {+ const task = selectedStage.value.taskList[0];if (state.create) {- return "";+ return (task as TaskCreate).statement;}-- const task = selectedStage.value.taskList[0];- return (task.payload as DatabaseSchemaUpdateTaskPayload).statement;+ return ((task as Task).payload as DatabaseSchemaUpdateTaskPayload)+ .statement;});const selectedRollbackStatement = computed((): string => {+ const task = selectedStage.value.taskList[0];if (state.create) {- return "";+ return (task as TaskCreate).rollbackStatement;}-- const task = selectedStage.value.taskList[0];- return (task.payload as DatabaseSchemaUpdateTaskPayload)+ return ((task as Task).payload as DatabaseSchemaUpdateTaskPayload).rollbackStatement;});@@ -710,7 +712,7 @@ export default {});const showPipelineFlowBar = computed(() => {- return !state.create && currentPipelineType.value != "NO_PIPELINE";+ return currentPipelineType.value != "NO_PIPELINE";});const showIssueOutputPanel = computed(() => {diff --git a/frontend/src/views/IssueSidebar.vue b/frontend/src/views/IssueSidebar.vueindex e97d797bcf..b60367ea05 100644--- a/frontend/src/views/IssueSidebar.vue+++ b/frontend/src/views/IssueSidebar.vue@@ -241,6 +241,7 @@ import {IssueCreate,EMPTY_ID,Stage,+ StageCreate,} from "../types";import { allTaskList, isDBAOrOwner } from "../utils";import { useRouter } from "vue-router";@@ -266,7 +267,7 @@ export default {},selectedStage: {required: true,- type: Object as PropType<Stage>,+ type: Object as PropType<Stage | StageCreate>,},inputFieldList: {required: true,@@ -299,21 +300,23 @@ export default {const database = computed((): Database => {if (props.create) {- const databaseId = (props.issue as IssueCreate).pipeline?.stageList[0]- .taskList[0].databaseId;- return store.getters["database/databaseById"](databaseId);+ const stage = props.selectedStage as StageCreate;+ return store.getters["database/databaseById"](+ stage.taskList[0].databaseId+ );}- const stage = props.selectedStage;+ const stage = props.selectedStage as Stage;return stage.taskList[0].database;});const environment = computed((): Environment => {if (props.create) {- const environmentId = (props.issue as IssueCreate).pipeline- ?.stageList[0].environmentId;- return store.getters["environment/environmentById"](environmentId);+ const stage = props.selectedStage as StageCreate;+ return store.getters["environment/environmentById"](+ stage.environmentId+ );}- const stage = props.selectedStage;+ const stage = props.selectedStage as Stage;return stage.environment;});diff --git a/frontend/src/views/PipelineSimpleFlow.vue b/frontend/src/views/PipelineSimpleFlow.vueindex 6c47c950ab..2605fc31ba 100644--- a/frontend/src/views/PipelineSimpleFlow.vue+++ b/frontend/src/views/PipelineSimpleFlow.vue@@ -151,7 +151,16 @@<script lang="ts">import { computed, PropType } from "vue";import { useRouter } from "vue-router";-import { Pipeline, TaskStatus, TaskId, Stage, StageId } from "../types";+import {+ Pipeline,+ TaskStatus,+ TaskId,+ Stage,+ StageId,+ StageCreate,+ PipelineCreate,+ Task,+} from "../types";import { activeTask } from "../utils";interface FlowItem {@@ -166,13 +175,17 @@ export default {name: "PipelineSimpleFlow",emits: ["select-stage-id"],props: {+ create: {+ required: true,+ type: Boolean,+ },pipeline: {required: true,- type: Object as PropType<Pipeline>,+ type: Object as PropType<Pipeline | PipelineCreate>,},selectedStage: {required: true,- type: Object as PropType<Stage>,+ type: Object as PropType<Stage | StageCreate>,},},components: {},@@ -180,12 +193,12 @@ export default {const router = useRouter();const itemList = computed<FlowItem[]>(() => {- return props.pipeline.stageList.map((stage) => {+ return props.pipeline.stageList.map((stage, index) => {const task = stage.taskList[0];return {- stageId: stage.id,+ stageId: props.create ? index : (stage as Stage).id,stageName: stage.name,- taskId: task.id,+ taskId: props.create ? index : (task as Task).id,taskName: task.name,taskStatus: task.status,};@@ -195,12 +208,18 @@ export default {const flowItemIconClass = (item: FlowItem) => {switch (item.taskStatus) {case "PENDING":- if (activeTask(props.pipeline).id === item.taskId) {+ if (+ !props.create &&+ activeTask(props.pipeline as Pipeline).id === item.taskId+ ) {return "bg-white border-2 border-blue-600 text-blue-600 ";}return "bg-white border-2 border-control";case "PENDING_APPROVAL":- if (activeTask(props.pipeline).id === item.taskId) {+ if (+ !props.create &&+ activeTask(props.pipeline as Pipeline).id === item.taskId+ ) {return "bg-white border-2 border-blue-600 text-blue-600";}return "bg-white border-2 border-control";@@ -215,10 +234,17 @@ export default {const flowItemTextClass = (item: FlowItem) => {let textClass =- activeTask(props.pipeline).id === item.taskId+ !props.create &&+ activeTask(props.pipeline as Pipeline).id === item.taskId? "font-bold ": "font-normal ";- if (item.stageId == props.selectedStage.id) {+ // For create, since we don't have stage id yet, we just compare name instead.+ // Not 100% accurate, but should be fine most of the time.+ if (+ (props.create &&+ item.stageName == (props.selectedStage as StageCreate).name) ||+ (!props.create && item.stageId == (props.selectedStage as Stage).id)+ ) {textClass += "underline ";}switch (item.taskStatus) {@@ -226,7 +252,10 @@ export default {return textClass + "text-control";case "PENDING":case "PENDING_APPROVAL":- if (activeTask(props.pipeline).id === item.taskId) {+ if (+ !props.create &&+ activeTask(props.pipeline as Pipeline).id === item.taskId+ ) {return textClass + "text-blue-600";}return textClass + "text-control";