Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: remove unused fields from stage and pipeline (#4406)
Danny Xud254859a3bf1
diff --git a/backend/legacyapi/pipeline.go b/backend/legacyapi/pipeline.goindex fbcae60dbf..1341b00bf6 100644--- a/backend/legacyapi/pipeline.go+++ b/backend/legacyapi/pipeline.go@@ -20,20 +20,12 @@ const (type Pipeline struct {ID int `jsonapi:"primary,pipeline"`- // Standard fields- CreatorID int- Creator *Principal `jsonapi:"relation,creator"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterID int- Updater *Principal `jsonapi:"relation,updater"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`-// Related fieldsStageList []*Stage `jsonapi:"relation,stage"`// Domain specific fields- Name string `jsonapi:"attr,name"`- Status PipelineStatus `jsonapi:"attr,status"`+ Name string `jsonapi:"attr,name"`+ Status PipelineStatus}// PipelineCreate is the API message for creating a pipeline.diff --git a/backend/legacyapi/stage.go b/backend/legacyapi/stage.goindex d637436fbe..bcf1618654 100644--- a/backend/legacyapi/stage.go+++ b/backend/legacyapi/stage.go@@ -23,14 +23,6 @@ const (type Stage struct {ID int `jsonapi:"primary,stage"`- // Standard fields- CreatorID int- Creator *Principal `jsonapi:"relation,creator"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterID int- Updater *Principal `jsonapi:"relation,updater"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`-// Related fields// Just returns PipelineID otherwise would cause circular dependency.PipelineID int `jsonapi:"attr,pipelineId"`diff --git a/backend/store/issue.go b/backend/store/issue.goindex 3a0320b686..25da5706c8 100644--- a/backend/store/issue.go+++ b/backend/store/issue.go@@ -115,15 +115,9 @@ func (s *Store) createPipelineValidateOnly(ctx context.Context, create *api.Pipeid := 0ts := time.Now().Unix()pipeline := &api.Pipeline{- ID: id,- Name: create.Name,- Status: api.PipelineOpen,- CreatorID: create.CreatorID,- Creator: creator,- CreatedTs: ts,- UpdaterID: create.CreatorID,- Updater: creator,- UpdatedTs: ts,+ ID: id,+ Name: create.Name,+ Status: api.PipelineOpen,}for _, sc := range create.StageList {id++@@ -134,12 +128,6 @@ func (s *Store) createPipelineValidateOnly(ctx context.Context, create *api.Pipestage := &api.Stage{ID: id,Name: sc.Name,- CreatorID: create.CreatorID,- Creator: creator,- CreatedTs: ts,- UpdaterID: create.CreatorID,- Updater: creator,- UpdatedTs: ts,PipelineID: sc.PipelineID,EnvironmentID: sc.EnvironmentID,Environment: env,diff --git a/backend/store/pipeline.go b/backend/store/pipeline.goindex 5731af12c8..358d94dd3f 100644--- a/backend/store/pipeline.go+++ b/backend/store/pipeline.go@@ -19,12 +19,6 @@ import (type pipelineRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Domain specific fieldsName stringStatus api.PipelineStatus@@ -36,12 +30,6 @@ func (raw *pipelineRaw) toPipeline() *api.Pipeline {return &api.Pipeline{ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-// Domain specific fieldsName: raw.Name,Status: raw.Status,@@ -123,18 +111,6 @@ func (s *Store) PatchPipeline(ctx context.Context, patch *api.PipelinePatch) (*afunc (s *Store) composePipeline(ctx context.Context, raw *pipelineRaw) (*api.Pipeline, error) {pipeline := raw.toPipeline()- creator, err := s.GetPrincipalByID(ctx, pipeline.CreatorID)- if err != nil {- return nil, err- }- pipeline.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, pipeline.UpdaterID)- if err != nil {- return nil, err- }- pipeline.Updater = updater-stageList, err := s.FindStage(ctx, &api.StageFind{PipelineID: &pipeline.ID})if err != nil {return nil, err@@ -263,7 +239,7 @@ func (*Store) createPipelineImpl(ctx context.Context, tx *Tx, create *api.Pipelistatus)VALUES ($1, $2, $3, 'OPEN')- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, status+ RETURNING id, name, status`var pipelineRaw pipelineRawif err := tx.QueryRowContext(ctx, query,@@ -272,10 +248,6 @@ func (*Store) createPipelineImpl(ctx context.Context, tx *Tx, create *api.Pipelicreate.Name,).Scan(&pipelineRaw.ID,- &pipelineRaw.CreatorID,- &pipelineRaw.CreatedTs,- &pipelineRaw.UpdaterID,- &pipelineRaw.UpdatedTs,&pipelineRaw.Name,&pipelineRaw.Status,); err != nil {@@ -300,10 +272,6 @@ func (*Store) findPipelineImpl(ctx context.Context, tx *Tx, find *api.PipelineFirows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,name,statusFROM pipeline@@ -321,10 +289,6 @@ func (*Store) findPipelineImpl(ctx context.Context, tx *Tx, find *api.PipelineFivar pipelineRaw pipelineRawif err := rows.Scan(&pipelineRaw.ID,- &pipelineRaw.CreatorID,- &pipelineRaw.CreatedTs,- &pipelineRaw.UpdaterID,- &pipelineRaw.UpdatedTs,&pipelineRaw.Name,&pipelineRaw.Status,); err != nil {@@ -356,15 +320,11 @@ func (*Store) patchPipelineImpl(ctx context.Context, tx *Tx, patch *api.PipelineUPDATE pipelineSET `+strings.Join(set, ", ")+`WHERE id = $%d- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, status+ RETURNING id, name, status`, len(args)),args...,).Scan(&pipelineRaw.ID,- &pipelineRaw.CreatorID,- &pipelineRaw.CreatedTs,- &pipelineRaw.UpdaterID,- &pipelineRaw.UpdatedTs,&pipelineRaw.Name,&pipelineRaw.Status,); err != nil {diff --git a/backend/store/stage.go b/backend/store/stage.goindex e371ff9d51..cb3bb7d979 100644--- a/backend/store/stage.go+++ b/backend/store/stage.go@@ -16,12 +16,6 @@ import (type stageRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Related fieldsPipelineID intEnvironmentID int@@ -36,12 +30,6 @@ func (raw *stageRaw) toStage() *api.Stage {return &api.Stage{ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-// Related fieldsPipelineID: raw.PipelineID,EnvironmentID: raw.EnvironmentID,@@ -93,18 +81,6 @@ func (s *Store) FindStage(ctx context.Context, find *api.StageFind) ([]*api.Stagfunc (s *Store) composeStage(ctx context.Context, raw *stageRaw) (*api.Stage, error) {stage := raw.toStage()- creator, err := s.GetPrincipalByID(ctx, stage.CreatorID)- if err != nil {- return nil, err- }- stage.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, stage.UpdaterID)- if err != nil {- return nil, err- }- stage.Updater = updater-env, err := s.GetEnvironmentByID(ctx, stage.EnvironmentID)if err != nil {return nil, err@@ -185,7 +161,7 @@ func (*Store) createStageImpl(ctx context.Context, tx *Tx, creates []*api.StageCenvironment_id,name) VALUES %s- RETURNING id, creator_id, created_ts, updater_id, updated_ts, pipeline_id, environment_id, name+ RETURNING id, pipeline_id, environment_id, name) SELECT * FROM inserted ORDER BY id ASC`, strings.Join(valueStr, ","))rows, err := tx.QueryContext(ctx, query, values...)@@ -199,10 +175,6 @@ func (*Store) createStageImpl(ctx context.Context, tx *Tx, creates []*api.StageCvar stageRaw stageRawif err := rows.Scan(&stageRaw.ID,- &stageRaw.CreatorID,- &stageRaw.CreatedTs,- &stageRaw.UpdaterID,- &stageRaw.UpdatedTs,&stageRaw.PipelineID,&stageRaw.EnvironmentID,&stageRaw.Name,@@ -231,10 +203,6 @@ func (*Store) findStageImpl(ctx context.Context, tx *Tx, find *api.StageFind) ([rows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,pipeline_id,environment_id,name@@ -253,10 +221,6 @@ func (*Store) findStageImpl(ctx context.Context, tx *Tx, find *api.StageFind) ([var stageRaw stageRawif err := rows.Scan(&stageRaw.ID,- &stageRaw.CreatorID,- &stageRaw.CreatedTs,- &stageRaw.UpdaterID,- &stageRaw.UpdatedTs,&stageRaw.PipelineID,&stageRaw.EnvironmentID,&stageRaw.Name,diff --git a/frontend/src/store/modules/pipeline.ts b/frontend/src/store/modules/pipeline.tsindex 6d8edc89e1..2c563e8734 100644--- a/frontend/src/store/modules/pipeline.ts+++ b/frontend/src/store/modules/pipeline.ts@@ -10,7 +10,6 @@ import {Attributes,unknown,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";import { useStageStore } from "./stage";function convert(@@ -34,19 +33,8 @@ function convert(}const result: Pipeline = {- ...(pipeline.attributes as Omit<- Pipeline,- "id" | "stageList" | "creator" | "updater"- >),+ ...(pipeline.attributes as Omit<Pipeline, "id" | "stageList">),id: parseInt(pipeline.id),- creator: getPrincipalFromIncludedList(- pipeline.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- pipeline.relationships!.updater.data,- includedList- ),stageList,};diff --git a/frontend/src/store/modules/stage.ts b/frontend/src/store/modules/stage.tsindex 67ee038f81..1965fa3d73 100644--- a/frontend/src/store/modules/stage.ts+++ b/frontend/src/store/modules/stage.ts@@ -10,7 +10,6 @@ import {Pipeline,Environment,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";import { useEnvironmentStore } from "./environment";import { useTaskStore } from "./task";@@ -53,19 +52,8 @@ function convertPartial(}const result: Omit<Stage, "pipeline"> = {- ...(stage.attributes as Omit<- Stage,- "id" | "database" | "taskList" | "creator" | "updater"- >),+ ...(stage.attributes as Omit<Stage, "id" | "database" | "taskList">),id: parseInt(stage.id),- creator: getPrincipalFromIncludedList(- stage.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- stage.relationships!.updater.data,- includedList- ),environment,taskList,};diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 8983e4babd..e6089e3f27 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -276,12 +276,7 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_PIPELINE: Pipeline = {id: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- createdTs: 0,- updater: UNKNOWN_PRINCIPAL,- updatedTs: 0,name: "<<Unknown pipeline>>",- status: "DONE",stageList: [],};@@ -320,10 +315,6 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_STAGE: Stage = {id: UNKNOWN_ID,pipeline: UNKNOWN_PIPELINE,- creator: UNKNOWN_PRINCIPAL,- createdTs: 0,- updater: UNKNOWN_PRINCIPAL,- updatedTs: 0,name: "<<Unknown stage>>",environment: UNKNOWN_ENVIRONMENT,taskList: [],@@ -641,12 +632,7 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_PIPELINE: Pipeline = {id: EMPTY_ID,- creator: EMPTY_PRINCIPAL,- createdTs: 0,- updater: EMPTY_PRINCIPAL,- updatedTs: 0,name: "",- status: "DONE",stageList: [],};@@ -685,10 +671,6 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_STAGE: Stage = {id: EMPTY_ID,pipeline: EMPTY_PIPELINE,- creator: EMPTY_PRINCIPAL,- createdTs: 0,- updater: EMPTY_PRINCIPAL,- updatedTs: 0,name: "",environment: EMPTY_ENVIRONMENT,taskList: [],diff --git a/frontend/src/types/pipeline/pipeline.ts b/frontend/src/types/pipeline/pipeline.tsindex de20d73804..fa7a5e047b 100644--- a/frontend/src/types/pipeline/pipeline.ts+++ b/frontend/src/types/pipeline/pipeline.ts@@ -1,5 +1,4 @@import { PipelineId } from "../id";-import { Principal } from "../principal";import { Stage, StageCreate } from "./stage";/*@@ -30,15 +29,8 @@ export type Pipeline = {// Related fieldsstageList: Stage[];- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Domain specific fieldsname: string;- status: PipelineStatus;};export type PipelineCreate = {diff --git a/frontend/src/types/pipeline/stage.ts b/frontend/src/types/pipeline/stage.tsindex e9bc4dd163..ff298e9e15 100644--- a/frontend/src/types/pipeline/stage.ts+++ b/frontend/src/types/pipeline/stage.ts@@ -2,7 +2,6 @@import { Environment } from "../environment";import { EnvironmentId, StageId } from "../id";-import { Principal } from "../principal";import { Pipeline } from "./pipeline";import { Task, TaskCreate, TaskStatus } from "./task";@@ -15,12 +14,6 @@ export type Stage = {pipeline: Pipeline;environment: Environment;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Domain specific fieldsname: string;};