Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Move database field from stage to task
天舟257238ad2326
diff --git a/frontend/src/miragejs/models/index.js b/frontend/src/miragejs/models/index.jsindex 7c2be148e2..1eaa387688 100644--- a/frontend/src/miragejs/models/index.js+++ b/frontend/src/miragejs/models/index.js@@ -103,7 +103,6 @@ export default {workspace: belongsTo(),pipeline: belongsTo(),environment: belongsTo(),- database: belongsTo(),}),stagePatch: Model,stageStatusPatch: Model,@@ -113,6 +112,7 @@ export default {workspace: belongsTo(),pipeline: belongsTo(),stage: belongsTo(),+ database: belongsTo(),}),taskPatch: Model,taskStatusPatch: Model,@@ -141,7 +141,7 @@ export default {instance: belongsTo(),project: belongsTo(),dataSource: hasMany(),- stage: hasMany(),+ task: hasMany(),}),databaseNew: Model,databasePatch: Model,diff --git a/frontend/src/miragejs/seeds/index.ts b/frontend/src/miragejs/seeds/index.tsindex d88dffe91b..0063ab5df8 100644--- a/frontend/src/miragejs/seeds/index.ts+++ b/frontend/src/miragejs/seeds/index.ts@@ -380,7 +380,6 @@ const workspacesSeeder = (server: any) => {// type: "bytebase.stage.database.create",// status: "PENDING",// environmentId: environmentList1[1].id,- // databaseId: databaseList1[1].id,// pipeline,// workspace: workspace1,// });@@ -391,6 +390,7 @@ const workspacesSeeder = (server: any) => {// name: "Waiting approval",// type: "bytebase.task.approve",// status: "PENDING",+ // databaseId: databaseList1[1].id,// pipeline,// stage,// workspace: workspace1,@@ -821,7 +821,6 @@ const createUpdateSchemaStage = (name: `${environmentList[i].name}`,type: "bytebase.stage.schema.update",environmentId: environmentList[i].id,- databaseId: databaseList[i].id,pipelineId,workspaceId,});@@ -843,6 +842,7 @@ const createUpdateSchemaStage = (name: `Update ${databaseList[i].name} schema`,type: "bytebase.task.schema.udpate",status: taskStatusList[i],+ databaseId: databaseList[i].id,pipelineId,stage,workspaceId,diff --git a/frontend/src/plugins/issue/DatabaseCreateTemplate.ts b/frontend/src/plugins/issue/DatabaseCreateTemplate.tsindex 2309a81acf..7e487e4b68 100644--- a/frontend/src/plugins/issue/DatabaseCreateTemplate.ts+++ b/frontend/src/plugins/issue/DatabaseCreateTemplate.ts@@ -29,7 +29,6 @@ const template: IssueTemplate = {{name: "Create database",environmentId: ctx.environmentList[0].id,- databaseId: EMPTY_ID,type: "bytebase.stage.database.create",taskList: [{diff --git a/frontend/src/plugins/issue/DatabaseGrantTemplate.ts b/frontend/src/plugins/issue/DatabaseGrantTemplate.tsindex 0ddea65861..19fe9f9d65 100644--- a/frontend/src/plugins/issue/DatabaseGrantTemplate.ts+++ b/frontend/src/plugins/issue/DatabaseGrantTemplate.ts@@ -30,11 +30,11 @@ const template: IssueTemplate = {name: "Request database access",type: "bytebase.stage.database.grant",environmentId: ctx.environmentList[0].id,- databaseId: ctx.databaseList[0].id,taskList: [{name: "Waiting for approval",type: "bytebase.task.approve",+ databaseId: ctx.databaseList[0].id,},],},diff --git a/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts b/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.tsindex 5b79b622f4..6f90eda42f 100644--- a/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts+++ b/frontend/src/plugins/issue/DatabaseSchemaUpdateTemplate.ts@@ -21,7 +21,6 @@ const template: IssueTemplate = {name: `[${ctx.databaseList[i].instance.environment.name}] ${ctx.databaseList[i].name}`,type: "bytebase.stage.schema.update",environmentId: ctx.environmentList[i].id,- databaseId: ctx.databaseList[i].id,taskList: [{name: "Waiting for approval",@@ -30,6 +29,7 @@ const template: IssueTemplate = {{name: `Update ${ctx.databaseList[i].name} schema`,type: "bytebase.task.database.schema.update",+ databaseId: ctx.databaseList[i].id,},],});diff --git a/frontend/src/store/modules/stage.ts b/frontend/src/store/modules/stage.tsindex 2ca5ee7368..6755cc3547 100644--- a/frontend/src/store/modules/stage.ts+++ b/frontend/src/store/modules/stage.ts@@ -35,14 +35,6 @@ function convertPartial((stage.relationships!.environment.data as ResourceIdentifier).id);- let database: Database = empty("DATABASE") as Database;- // For create database stage, there is no database id.- if (stage.relationships!.database.data) {- database = rootGetters["database/databaseById"](- (stage.relationships!.database.data as ResourceIdentifier).id- );- }-const taskList: Task[] = [];for (const item of includedList || []) {if (@@ -63,7 +55,6 @@ function convertPartial(creator,updater,environment,- database,taskList,};diff --git a/frontend/src/store/modules/task.ts b/frontend/src/store/modules/task.tsindex 7d4c43b3ce..5fa80cb866 100644--- a/frontend/src/store/modules/task.ts+++ b/frontend/src/store/modules/task.ts@@ -11,6 +11,9 @@ import {Pipeline,TaskStatusPatch,TaskId,+ Database,+ empty,+ ResourceIdentifier,} from "../../types";const state: () => TaskState = () => ({});@@ -26,14 +29,23 @@ function convertPartial(task.attributes.updaterId);+ let database: Database = empty("DATABASE") as Database;+ // For create database stage, there is no database id.+ if (task.relationships!.database.data) {+ database = rootGetters["database/databaseById"](+ (task.relationships!.database.data as ResourceIdentifier).id+ );+ }+return {...(task.attributes as Omit<Task,- "id" | "creator" | "updater" | "pipeline" | "stage"+ "id" | "creator" | "updater" | "database" | "pipeline" | "stage">),id: task.id,creator,updater,+ database,};}diff --git a/frontend/src/types/bytebase.ts b/frontend/src/types/bytebase.tsindex 6d76b50462..55d2bf1708 100644--- a/frontend/src/types/bytebase.ts+++ b/frontend/src/types/bytebase.ts@@ -201,7 +201,6 @@ export const unknown = (name: "<<Unknown stage>>",type: "bytebase.stage.unknown",environment: UNKNOWN_ENVIRONMENT,- database: UNKNOWN_DATABASE,taskList: [],};@@ -216,6 +215,7 @@ export const unknown = (name: "<<Unknown task>>",type: "bytebase.task.unknown",status: "DONE",+ database: UNKNOWN_DATABASE,};const UNKNOWN_ACTIVITY: Activity = {@@ -457,7 +457,6 @@ export const empty = (name: "",type: "bytebase.stage.unknown",environment: EMPTY_ENVIRONMENT,- database: EMPTY_DATABASE,taskList: [],};@@ -472,6 +471,7 @@ export const empty = (name: "",type: "bytebase.task.unknown",status: "DONE",+ database: EMPTY_DATABASE,};const EMPTY_ACTIVITY: Activity = {@@ -1097,8 +1097,6 @@ export type Stage = {taskList: Task[];pipeline: Pipeline;environment: Environment;- // We may get an empty database for stages like creating database.- database: Database;// Standard fieldscreator: Principal;@@ -1116,7 +1114,6 @@ export type StageNew = {// Related fieldstaskList: TaskNew[];environmentId: EnvironmentId;- databaseId: DatabaseId;// Domain specific fieldsname: string;@@ -1157,6 +1154,8 @@ export type Task = {name: string;type: TaskType;status: TaskStatus;+ // We may get an empty database for tasks like creating database.+ database: Database;payload?: TaskPayload;};@@ -1164,6 +1163,7 @@ export type TaskNew = {// Domain specific fieldsname: string;type: TaskType;+ databaseId?: DatabaseId;};export type TaskPatch = {diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.tsindex 8a9038ff44..8347cc9583 100644--- a/frontend/src/utils/pipeline.ts+++ b/frontend/src/utils/pipeline.ts@@ -81,11 +81,11 @@ export function activeEnvironment(pipeline: Pipeline): Environment {}export function activeDatabase(pipeline: Pipeline): Database {- const stage = activeStage(pipeline);- if (stage.id == EMPTY_ID) {+ const task = activeTask(pipeline);+ if (task.id == EMPTY_ID) {return empty("DATABASE") as Database;}- return stage.database;+ return task.database;}export type TaskStatusTransitionType = "RUN" | "RETRY" | "CANCEL" | "SKIP";diff --git a/frontend/src/views/IssueSidebar.vue b/frontend/src/views/IssueSidebar.vueindex 0b5713cc31..53af48ec61 100644--- a/frontend/src/views/IssueSidebar.vue+++ b/frontend/src/views/IssueSidebar.vue@@ -302,7 +302,7 @@ export default {(): Database => {if (props.new) {const databaseId = (props.issue as IssueNew).pipeline?.stageList[0]- .databaseId;+ .taskList[0].databaseId;return store.getters["database/databaseById"](databaseId);}return activeDatabase((props.issue as Issue).pipeline);