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 creator/updater (#4205)
Danny Xu09aad4075e59
diff --git a/api/data_source.go b/api/data_source.goindex 36c053c20a..ef784c861d 100644--- a/api/data_source.go+++ b/api/data_source.go@@ -74,14 +74,6 @@ func (d *DataSourceOptions) Scan(src interface{}) error {type DataSource struct {ID int `jsonapi:"primary,dataSource"`- // 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 InstanceID and DatabaseID otherwise would cause circular dependency.InstanceID int `jsonapi:"attr,instanceId"`diff --git a/api/database.go b/api/database.goindex 0d332ec160..0e2c941e18 100644--- a/api/database.go+++ b/api/database.go@@ -23,22 +23,12 @@ const (type Database struct {ID int `jsonapi:"primary,database"`- // 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 fieldsProjectID int `jsonapi:"attr,projectId"`Project *Project `jsonapi:"relation,project"`InstanceID int `jsonapi:"attr,instanceId"`Instance *Instance `jsonapi:"relation,instance"`DataSourceList []*DataSource `jsonapi:"relation,dataSource"`- SourceBackupID int- SourceBackup *Backup `jsonapi:"relation,sourceBackup"`// Domain specific fieldsName string `jsonapi:"attr,name"`@@ -76,24 +66,12 @@ func (find *DatabaseFind) String() string {// DatabasePatch is the API message for patching a database.type DatabasePatch struct {- ID int-- // Standard fields- // Value is assigned from the jwt subject field passed by the client.- UpdaterID int-// Related fields- ProjectID *int `jsonapi:"attr,projectId"`- SourceBackupID *int+ ProjectID *int `jsonapi:"attr,projectId"`// Labels is a json-encoded string from a list of DatabaseLabel,// e.g. "[{"key":"bb.location","value":"earth"},{"key":"bb.tenant","value":"bytebase"}]".Labels *string `jsonapi:"attr,labels"`-- // Domain specific fields- SchemaVersion *string- SyncStatus *SyncStatus- LastSuccessfulSyncTs *int64}// DatabaseEdit is the API message for updating a database in UI editor.diff --git a/api/deploy.go b/api/deploy.goindex c9e5d5af82..fefb83ff0c 100644--- a/api/deploy.go+++ b/api/deploy.go@@ -10,14 +10,6 @@ import (type DeploymentConfig struct {ID int `jsonapi:"primary,deploymentConfig"`- // 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 fieldsProjectID intProject *Project `jsonapi:"relation,project"`diff --git a/api/label.go b/api/label.goindex 6c778af0c4..372349437d 100644--- a/api/label.go+++ b/api/label.go@@ -18,27 +18,3 @@ type DatabaseLabel struct {Key string `json:"key"`Value string `json:"value"`}--// DatabaseLabelFind finds the labels associated with the database.-type DatabaseLabelFind struct {- // Standard fields- RowStatus *RowStatus-- // Related fields- DatabaseID int-}--// DatabaseLabelUpsert upserts the label associated with the database.-type DatabaseLabelUpsert struct {- // Standard fields- // Value is assigned from the jwt subject field passed by the client.- UpdaterID int- RowStatus RowStatus-- // Related fields- DatabaseID int- Key string-- // Domain specific fields- Value string-}diff --git a/api/label_test.go b/api/label_test.goindex 2b6fbd89b7..094f5257f6 100644--- a/api/label_test.go+++ b/api/label_test.go@@ -20,10 +20,7 @@ func TestUnmarshal(t *testing.T) {}`)keys := []string{"bb.location", "bb.tenant"}values := []string{"earth", "bytebase"}- databasePatch := &DatabasePatch{- ID: 1,- UpdaterID: 1,- }+ databasePatch := &DatabasePatch{}err := jsonapi.UnmarshalPayload(bytes.NewReader(b), databasePatch)require.NoError(t, err)var labels []*DatabaseLabeldiff --git a/api/principal.go b/api/principal.goindex 9df9c0d3f0..442bfcfe2b 100644--- a/api/principal.go+++ b/api/principal.go@@ -41,12 +41,6 @@ const (type Principal struct {ID int `jsonapi:"primary,principal"`- // Standard fields- CreatorID int `jsonapi:"attr,creatorId"`- CreatedTs int64 `jsonapi:"attr,createdTs"`- UpdaterID int `jsonapi:"attr,updaterId"`- UpdatedTs int64 `jsonapi:"attr,updatedTs"`-// Domain specific fieldsType PrincipalType `jsonapi:"attr,type"`Name string `jsonapi:"attr,name"`@@ -66,10 +60,6 @@ type Principal struct {func (p *Principal) MarshalJSON() ([]byte, error) {return json.Marshal(&struct {ID int `json:"id"`- CreatorID int `json:"creatorId"`- CreatedTs int64 `json:"createdTs"`- UpdaterID int `json:"updaterId"`- UpdatedTs int64 `json:"updatedTs"`Type PrincipalType `json:"type"`Name string `json:"name"`Email string `json:"email"`@@ -77,10 +67,6 @@ func (p *Principal) MarshalJSON() ([]byte, error) {ServiceKey string `json:"serviceKey"`}{ID: p.ID,- CreatorID: p.CreatorID,- CreatedTs: p.CreatedTs,- UpdaterID: p.UpdaterID,- UpdatedTs: p.UpdatedTs,Type: p.Type,Name: p.Name,Email: p.Email,@@ -91,11 +77,6 @@ func (p *Principal) MarshalJSON() ([]byte, error) {// PrincipalCreate is the API message for creating a principal.type PrincipalCreate struct {- // Standard fields- // For signup, value is SYSTEM_BOT_ID- // For invite, value is assigned from the jwt subject field passed by the client.- CreatorID int-// Domain specific fieldsType PrincipalType `jsonapi:"attr,type"`Name string `jsonapi:"attr,name"`@@ -104,30 +85,8 @@ type PrincipalCreate struct {PasswordHash string}-// PrincipalFind is the API message for finding principals.-type PrincipalFind struct {- ID *int-- // Domain specific fields- Email *string-}--func (find *PrincipalFind) String() string {- str, err := json.Marshal(*find)- if err != nil {- return err.Error()- }- return string(str)-}-// PrincipalPatch is the API message for patching a principal.type PrincipalPatch struct {- ID int-- // Standard fields- // Value is assigned from the jwt subject field passed by the client.- UpdaterID int-// Domain specific fieldsType PrincipalType `jsonapi:"attr,type"`Name *string `jsonapi:"attr,name"`diff --git a/api/project_webhook.go b/api/project_webhook.goindex 5fbd61faa0..ba9fbdd570 100644--- a/api/project_webhook.go+++ b/api/project_webhook.go@@ -8,14 +8,6 @@ import (type ProjectWebhook struct {ID int `jsonapi:"primary,projectWebhookMember"`- // 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 ProjectID since it always operates within the project contextProjectID int `jsonapi:"attr,projectId"`diff --git a/api/repository.go b/api/repository.goindex ca7b64b6e1..8bd0b8fdb7 100644--- a/api/repository.go+++ b/api/repository.go@@ -8,14 +8,6 @@ import (type Repository struct {ID int `jsonapi:"primary,repository"`- // 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 fieldsVCSID intVCS *VCS `jsonapi:"relation,vcs"`diff --git a/api/setting.go b/api/setting.goindex 67f1517588..ea1ec6d300 100644--- a/api/setting.go+++ b/api/setting.go@@ -32,14 +32,6 @@ const IMTypeFeishu IMType = "im.feishu"type Setting struct {ID int `jsonapi:"primary,setting"`- // 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"`-// Domain specific fieldsName SettingName `jsonapi:"attr,name"`Value string `jsonapi:"attr,value"`diff --git a/api/vcs.go b/api/vcs.goindex 6d5ef3f134..7699d93538 100644--- a/api/vcs.go+++ b/api/vcs.go@@ -11,14 +11,6 @@ import (type VCS struct {ID int `jsonapi:"primary,vcs"`- // 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"`-// Domain specific fieldsName string `jsonapi:"attr,name"`Type vcs.Type `jsonapi:"attr,type"`diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 7fe368cf4e..9118921a75 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -882,8 +882,6 @@"last-successful-sync": "Last successful sync","search-database-name": "Search database name","search-database": "Search database",- "restored-from": "Restored from ",- "database-name-is-restored-from-another-database-backup": "{0} is restored from another database backup","database-backup": "database backup","transfer-project": "Transfer Project","alter-schema": "Alter Schema",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 64a3c6060e..49e135cf8e 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -882,8 +882,6 @@"sync-status": "同步状态","search-database-name": "搜索数据库名称","search-database": "搜索数据库",- "restored-from": "恢复于",- "database-name-is-restored-from-another-database-backup": "{0}恢复于另一个数据库备份","transfer-project": "转移项目","alter-schema": "变更 Schema","alter-schema-in-vcs": "变更 Schema (VCS)",diff --git a/frontend/src/store/modules/dataSource.ts b/frontend/src/store/modules/dataSource.tsindex 4e81b50a0c..aa145f9ee0 100644--- a/frontend/src/store/modules/dataSource.ts+++ b/frontend/src/store/modules/dataSource.ts@@ -12,7 +12,6 @@ import {EMPTY_ID,empty,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";function convert(dataSource: ResourceObject,@@ -24,19 +23,11 @@ function convert(return {...(dataSource.attributes as Omit<DataSource,- "id" | "instanceId" | "databaseId" | "creator" | "updater"+ "id" | "instanceId" | "databaseId">),id: parseInt(dataSource.id),databaseId: parseInt(databaseId),instanceId: parseInt(instanceId),- creator: getPrincipalFromIncludedList(- dataSource.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- dataSource.relationships!.updater.data,- includedList- ),};}diff --git a/frontend/src/store/modules/database.ts b/frontend/src/store/modules/database.tsindex 00ed38269a..a2b0c0fefa 100644--- a/frontend/src/store/modules/database.ts+++ b/frontend/src/store/modules/database.ts@@ -2,7 +2,6 @@ import { defineStore } from "pinia";import axios from "axios";import { computed, unref, watch, markRaw } from "vue";import {- Backup,Database,DatabaseFind,DatabaseId,@@ -23,8 +22,6 @@ import {unknown,UNKNOWN_ID,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";-import { useBackupStore } from "./backup";import { useDataSourceStore } from "./dataSource";import { useInstanceStore } from "./instance";import { useProjectStore } from "./project";@@ -56,14 +53,8 @@ function convert(dataSourceList.push(dataSource);}- const sourceBackupId = database.relationships!.sourceBackup.data- ? (database.relationships!.sourceBackup.data as ResourceIdentifier).id- : undefined;- let sourceBackup: Backup | undefined = undefined;-const instanceStore = useInstanceStore();const projectStore = useProjectStore();- const backupStore = useBackupStore();for (const item of includedList || []) {if (item.type == "instance" && item.id == instanceId) {instance = instanceStore.convert(item, includedList);@@ -71,9 +62,6 @@ function convert(if (item.type == "project" && item.id == projectId) {project = projectStore.convert(item, includedList);}- if (item.type == "backup" && item.id == sourceBackupId) {- sourceBackup = backupStore.convert(item, includedList);- }}const labels: DatabaseLabel[] = [];@@ -99,29 +87,13 @@ function convert(const databaseWPartial = {...(database.attributes as Omit<Database,- | "id"- | "instance"- | "project"- | "dataSourceList"- | "sourceBackup"- | "labels"- | "creator"- | "updater"+ "id" | "instance" | "project" | "dataSourceList" | "labels">),id: parseInt(database.id),- creator: getPrincipalFromIncludedList(- database.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- database.relationships!.updater.data,- includedList- ),instance,project,labels,dataSourceList: [],- sourceBackup,};for (const item of includedList || []) {diff --git a/frontend/src/store/modules/deployment.ts b/frontend/src/store/modules/deployment.tsindex 81ae171714..9851dfda8f 100644--- a/frontend/src/store/modules/deployment.ts+++ b/frontend/src/store/modules/deployment.ts@@ -10,7 +10,6 @@ import {UNKNOWN_ID,DeploymentConfigPatch,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";function convert(deployment: ResourceObject,@@ -37,19 +36,8 @@ function convert(}return {- ...(deployment.attributes as Omit<- DeploymentConfig,- "id" | "schedule" | "creator" | "updater"- >),+ ...(deployment.attributes as Omit<DeploymentConfig, "id" | "schedule">),id: parseInt(deployment.id, 10),- creator: getPrincipalFromIncludedList(- deployment.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- deployment.relationships!.updater.data,- includedList- ),schedule,};}diff --git a/frontend/src/store/modules/principal.ts b/frontend/src/store/modules/principal.tsindex 8c5d8455c9..57b01b76ca 100644--- a/frontend/src/store/modules/principal.ts+++ b/frontend/src/store/modules/principal.ts@@ -20,10 +20,6 @@ import { useAuthStore } from "./auth";function convert(principal: ResourceObject): Principal {return {id: parseInt(principal.id),- creatorId: principal.attributes.creatorId as PrincipalId,- createdTs: principal.attributes.createdTs as number,- updaterId: principal.attributes.updaterId as PrincipalId,- updatedTs: principal.attributes.updatedTs as number,type: principal.attributes.type as PrincipalType,name: principal.attributes.name as string,email: principal.attributes.email as string,diff --git a/frontend/src/store/modules/projectWebhook.ts b/frontend/src/store/modules/projectWebhook.tsindex 7047778df9..229713b282 100644--- a/frontend/src/store/modules/projectWebhook.ts+++ b/frontend/src/store/modules/projectWebhook.ts@@ -11,26 +11,14 @@ import {ResourceObject,unknown,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";function convert(projectWebhook: ResourceObject,includedList: ResourceObject[]): ProjectWebhook {return {- ...(projectWebhook.attributes as Omit<- ProjectWebhook,- "id" | "creator" | "updater"- >),+ ...(projectWebhook.attributes as Omit<ProjectWebhook, "id">),id: parseInt(projectWebhook.id),- creator: getPrincipalFromIncludedList(- projectWebhook.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- projectWebhook.relationships!.updater.data,- includedList- ),};}diff --git a/frontend/src/store/modules/repository.ts b/frontend/src/store/modules/repository.tsindex 6b895d4c9d..10a66dbf03 100644--- a/frontend/src/store/modules/repository.ts+++ b/frontend/src/store/modules/repository.ts@@ -15,7 +15,6 @@ import {VCS,VCSId,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";import { useProjectStore } from "./project";import { useVCSStore } from "./vcs";@@ -45,19 +44,8 @@ function convert(}return {- ...(repository.attributes as Omit<- Repository,- "id" | "vcs" | "project" | "creator" | "updater"- >),+ ...(repository.attributes as Omit<Repository, "id" | "vcs" | "project">),id: parseInt(repository.id),- creator: getPrincipalFromIncludedList(- repository.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- repository.relationships!.updater.data,- includedList- ),vcs,project,};diff --git a/frontend/src/store/modules/setting.ts b/frontend/src/store/modules/setting.tsindex 842b6d8f82..1186d09968 100644--- a/frontend/src/store/modules/setting.ts+++ b/frontend/src/store/modules/setting.ts@@ -2,23 +2,14 @@ import { defineStore } from "pinia";import axios from "axios";import { ResourceObject, SettingState } from "@/types";import { Setting, SettingName } from "@/types/setting";-import { getPrincipalFromIncludedList } from "./principal";function convert(setting: ResourceObject,includedList: ResourceObject[]): Setting {return {- ...(setting.attributes as Omit<Setting, "id" | "creator" | "updater">),+ ...(setting.attributes as Omit<Setting, "id">),id: parseInt(setting.id),- creator: getPrincipalFromIncludedList(- setting.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- setting.relationships!.updater.data,- includedList- ),};}diff --git a/frontend/src/store/modules/vcs.ts b/frontend/src/store/modules/vcs.tsindex caf559ff3b..c3ac3aa9ee 100644--- a/frontend/src/store/modules/vcs.ts+++ b/frontend/src/store/modules/vcs.ts@@ -11,20 +11,11 @@ import {empty,EMPTY_ID,} from "@/types";-import { getPrincipalFromIncludedList } from "./principal";function convert(vcs: ResourceObject, includedList: ResourceObject[]): VCS {return {- ...(vcs.attributes as Omit<VCS, "id" | "creator" | "updater">),+ ...(vcs.attributes as Omit<VCS, "id">),id: parseInt(vcs.id),- creator: getPrincipalFromIncludedList(- vcs.relationships!.creator.data,- includedList- ),- updater: getPrincipalFromIncludedList(- vcs.relationships!.updater.data,- includedList- ),};}@@ -73,7 +64,7 @@ export const useVCSStore = defineStore("vcs", {return convert(vcs, data.included);}).sort((a: VCS, b: VCS) => {- return b.createdTs - a.createdTs;+ return b.id - a.id;});this.setVCSList(vcsList);diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 0adde0de73..66300eb750 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -166,10 +166,6 @@ const makeUnknown = (type: ResourceType) => {// Have to omit creator and updater to avoid recursion.const UNKNOWN_PRINCIPAL: Principal = {id: UNKNOWN_ID,- creatorId: UNKNOWN_ID,- createdTs: 0,- updaterId: UNKNOWN_ID,- updatedTs: 0,type: "END_USER",name: "<<Unknown principal>>",email: "",@@ -212,10 +208,6 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_PROJECT_HOOK: ProjectWebhook = {id: UNKNOWN_ID,projectId: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- updater: UNKNOWN_PRINCIPAL,- createdTs: 0,- updatedTs: 0,type: "",name: "",url: "",@@ -257,10 +249,6 @@ const makeUnknown = (type: ResourceType) => {project: UNKNOWN_PROJECT,labels: [],dataSourceList: [],- creator: UNKNOWN_PRINCIPAL,- createdTs: 0,- updater: UNKNOWN_PRINCIPAL,- updatedTs: 0,name: "<<Unknown database>>",characterSet: "",collation: "",@@ -273,10 +261,6 @@ const makeUnknown = (type: ResourceType) => {id: UNKNOWN_ID,instanceId: UNKNOWN_ID,databaseId: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- createdTs: 0,- updater: UNKNOWN_PRINCIPAL,- updatedTs: 0,name: "<<Unknown data source>>",type: "RO",username: "",@@ -420,10 +404,6 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_VCS: VCS = {id: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- updater: UNKNOWN_PRINCIPAL,- createdTs: 0,- updatedTs: 0,name: "",type: "GITLAB_SELF_HOST",instanceUrl: "",@@ -434,10 +414,6 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_REPOSITORY: Repository = {id: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- updater: UNKNOWN_PRINCIPAL,- createdTs: 0,- updatedTs: 0,vcs: UNKNOWN_VCS,project: UNKNOWN_PROJECT,name: "",@@ -474,10 +450,6 @@ const makeUnknown = (type: ResourceType) => {const UNKNOWN_DEPLOYMENT_CONFIG: DeploymentConfig = {id: UNKNOWN_ID,- creator: UNKNOWN_PRINCIPAL,- createdTs: 0,- updater: UNKNOWN_PRINCIPAL,- updatedTs: 0,project: UNKNOWN_PROJECT,schedule: {deployments: [],@@ -578,8 +550,6 @@ const makeEmpty = (type: ResourceType) => {// Have to omit creator and updater to avoid recursion.const EMPTY_PRINCIPAL: Principal = {id: EMPTY_ID,- createdTs: 0,- updatedTs: 0,type: "END_USER",name: "",email: "",@@ -622,10 +592,6 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_PROJECT_HOOK: ProjectWebhook = {id: EMPTY_ID,projectId: EMPTY_ID,- creator: EMPTY_PRINCIPAL,- updater: EMPTY_PRINCIPAL,- createdTs: 0,- updatedTs: 0,type: "",name: "",url: "",@@ -667,10 +633,6 @@ const makeEmpty = (type: ResourceType) => {project: EMPTY_PROJECT,dataSourceList: [],labels: [],- creator: EMPTY_PRINCIPAL,- createdTs: 0,- updater: EMPTY_PRINCIPAL,- updatedTs: 0,name: "",characterSet: "",collation: "",@@ -683,10 +645,6 @@ const makeEmpty = (type: ResourceType) => {id: EMPTY_ID,instanceId: UNKNOWN_ID,databaseId: UNKNOWN_ID,- creator: EMPTY_PRINCIPAL,- createdTs: 0,- updater: EMPTY_PRINCIPAL,- updatedTs: 0,name: "",type: "RO",username: "",@@ -830,10 +788,6 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_VCS: VCS = {id: EMPTY_ID,- creator: EMPTY_PRINCIPAL,- updater: EMPTY_PRINCIPAL,- createdTs: 0,- updatedTs: 0,name: "",type: "GITLAB_SELF_HOST",instanceUrl: "",@@ -844,10 +798,6 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_REPOSITORY: Repository = {id: EMPTY_ID,- creator: EMPTY_PRINCIPAL,- updater: EMPTY_PRINCIPAL,- createdTs: 0,- updatedTs: 0,vcs: EMPTY_VCS,project: EMPTY_PROJECT,name: "",@@ -884,10 +834,6 @@ const makeEmpty = (type: ResourceType) => {const EMPTY_DEPLOYMENT_CONFIG: DeploymentConfig = {id: EMPTY_ID,- creator: EMPTY_PRINCIPAL,- createdTs: 0,- updater: EMPTY_PRINCIPAL,- updatedTs: 0,project: EMPTY_PROJECT,schedule: {deployments: [],diff --git a/frontend/src/types/dataSource.ts b/frontend/src/types/dataSource.tsindex e40ce33c82..67bd31826d 100644--- a/frontend/src/types/dataSource.ts+++ b/frontend/src/types/dataSource.ts@@ -26,12 +26,6 @@ export type DataSource = {databaseId: DatabaseId;instanceId: InstanceId;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Domain specific fieldsname: string;type: DataSourceType;diff --git a/frontend/src/types/database.ts b/frontend/src/types/database.tsindex fe7159fe1a..64f3abb037 100644--- a/frontend/src/types/database.ts+++ b/frontend/src/types/database.ts@@ -2,11 +2,9 @@// in the "database" object.// Physically, a database belongs to an instance. Logically, it belongs to a project.-import { Backup } from "./backup";import { DataSource } from "./dataSource";import { DatabaseId, InstanceId, ProjectId } from "./id";import { Instance } from "./instance";-import { Principal } from "./principal";import { Project } from "./project";import { DatabaseLabel } from "./label";@@ -23,13 +21,6 @@ export type Database = {instanceId: InstanceId;instance: Instance;dataSourceList: DataSource[];- sourceBackup?: Backup;-- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;// Domain specific fieldssyncStatus: DatabaseSyncStatus;diff --git a/frontend/src/types/deployment.ts b/frontend/src/types/deployment.tsindex fe07f512c5..6b4e6644db 100644--- a/frontend/src/types/deployment.ts+++ b/frontend/src/types/deployment.ts@@ -1,17 +1,10 @@import { Project } from ".";import { DeploymentConfigId } from "./id";import { LabelKeyType, LabelValueType } from "./label";-import { Principal } from "./principal";export type DeploymentConfig = {id: DeploymentConfigId;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Related fieldsproject: Project;diff --git a/frontend/src/types/label.ts b/frontend/src/types/label.tsindex 1a7d77c760..1d5267e498 100644--- a/frontend/src/types/label.ts+++ b/frontend/src/types/label.ts@@ -6,10 +6,6 @@ export type LabelValueType = string;export type Label = {id: LabelId;- // Standard fields- createdTs: number;- updatedTs: number;-// Domain specific fieldskey: LabelKeyType;valueList: LabelValueType[];diff --git a/frontend/src/types/principal.ts b/frontend/src/types/principal.tsindex 4d7774cd80..ca7df1f5c7 100644--- a/frontend/src/types/principal.ts+++ b/frontend/src/types/principal.ts@@ -9,14 +9,6 @@ export type PrincipalType = "END_USER" | "SYSTEM_BOT" | "SERVICE_ACCOUNT";export type Principal = {id: PrincipalId;- // Standard fields- // Unlike other models, we use creatorId and updaterId instead of converting- // them to full principal object to avoid recursive issue.- creatorId: PrincipalId;- createdTs: number;- updaterId: PrincipalId;- updatedTs: number;-// Domain specific fieldstype: PrincipalType;name: string;diff --git a/frontend/src/types/projectWebhook.ts b/frontend/src/types/projectWebhook.tsindex d42cbf4fb5..faedf77ac2 100644--- a/frontend/src/types/projectWebhook.ts+++ b/frontend/src/types/projectWebhook.ts@@ -1,6 +1,5 @@import { ActivityType } from "./activity";import { MemberId, ProjectId } from "./id";-import { Principal } from "./principal";import { t } from "../plugins/i18n";type ProjectWebhookTypeItem = {@@ -96,12 +95,6 @@ export type ProjectWebhook = {// Related fieldsprojectId: ProjectId;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Domain specific fieldstype: string;name: string;diff --git a/frontend/src/types/repository.ts b/frontend/src/types/repository.tsindex 8c8ef3adc3..f879a114ee 100644--- a/frontend/src/types/repository.ts+++ b/frontend/src/types/repository.ts@@ -1,18 +1,11 @@import isEmpty from "lodash-es/isEmpty";import { RepositoryId, VCSId } from "./id";-import { Principal } from "./principal";import { Project } from "./project";import { VCS } from "./vcs";export type Repository = {id: RepositoryId;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Related fieldsvcs: VCS;project: Project;diff --git a/frontend/src/types/setting.ts b/frontend/src/types/setting.tsindex f4a0e45cde..f2c7ab0e4d 100644--- a/frontend/src/types/setting.ts+++ b/frontend/src/types/setting.ts@@ -1,17 +1,10 @@import { SettingId } from "./id";-import { Principal } from "./principal";export type SettingName = "bb.branding.logo" | "bb.app.im";export type Setting = {id: SettingId;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Domain specific fieldsname: SettingName;value: string;diff --git a/frontend/src/types/vcs.ts b/frontend/src/types/vcs.tsindex 2977d7bfac..f939ec00c4 100644--- a/frontend/src/types/vcs.ts+++ b/frontend/src/types/vcs.ts@@ -1,5 +1,4 @@import { VCSId } from "./id";-import { Principal } from "./principal";export type VCSType = "GITLAB_SELF_HOST" | "GITHUB_COM";@@ -14,12 +13,6 @@ export interface VCSConfig {export type VCS = {id: VCSId;- // Standard fields- creator: Principal;- createdTs: number;- updater: Principal;- updatedTs: number;-// Domain specific fieldsname: string;type: VCSType;diff --git a/frontend/src/views/DatabaseDetail.vue b/frontend/src/views/DatabaseDetail.vueindex 4bdc3183d9..1dbe42618a 100644--- a/frontend/src/views/DatabaseDetail.vue+++ b/frontend/src/views/DatabaseDetail.vue@@ -72,29 +72,6 @@>{{ projectName(database.project) }}</router-link></dd>- <template v-if="database.sourceBackup">- <dt class="sr-only">{{ $t("db.parent") }}</dt>- <dd class="flex items-center text-sm md:mr-4 tooltip-wrapper">- <span class="textlabel">{{- $t("database.restored-from")- }}</span>- <router-link- :to="`/db/${database.sourceBackup.databaseId}`"- class="normal-link"- >- <!-- Do not display the name of the backup's database because that requires a fetch -->- <span class="tooltip">- {{- $t(- "database.database-name-is-restored-from-another-database-backup",- [database.name]- )- }}- </span>- {{ $t("database.database-backup") }}- </router-link>- </dd>- </template><ddclass="flex items-center text-sm md:mr-4":class="diff --git a/server/auth.go b/server/auth.goindex 2d70e96166..86f3b9365f 100644--- a/server/auth.go+++ b/server/auth.go@@ -176,8 +176,6 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {composedUser := &api.Principal{ID: user.ID,- CreatorID: api.SystemBotID,- UpdaterID: api.SystemBotID,Type: user.Type,Name: user.Name,Email: user.Email,diff --git a/server/database.go b/server/database.goindex f712135976..4669473a9c 100644--- a/server/database.go+++ b/server/database.go@@ -120,10 +120,7 @@ func (s *Server) registerDatabaseRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Database not found with ID %d", id))}- dbPatch := &api.DatabasePatch{- ID: id,- UpdaterID: updaterID,- }+ dbPatch := &api.DatabasePatch{}if err := jsonapi.UnmarshalPayload(c.Request().Body, dbPatch); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformed patch database request").SetInternal(err)}diff --git a/server/principal.go b/server/principal.goindex 99d5a5415b..af5289e3a4 100644--- a/server/principal.go+++ b/server/principal.go@@ -50,8 +50,6 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {}principal := &api.Principal{ID: user.ID,- CreatorID: api.SystemBotID,- UpdaterID: api.SystemBotID,Type: user.Type,Name: user.Name,Email: user.Email,@@ -113,10 +111,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("principalID"))).SetInternal(err)}- principalPatch := &api.PrincipalPatch{- ID: id,- UpdaterID: c.Get(getPrincipalIDContextKey()).(int),- }+ principalPatch := &api.PrincipalPatch{}if err := jsonapi.UnmarshalPayload(c.Request().Body, principalPatch); err != nil {return echo.NewHTTPError(http.StatusBadRequest, "Malformed patch principal request").SetInternal(err)}@@ -150,8 +145,6 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {}principal := &api.Principal{ID: user.ID,- CreatorID: api.SystemBotID,- UpdaterID: api.SystemBotID,Type: user.Type,Name: user.Name,Email: user.Email,diff --git a/store/data_source.go b/store/data_source.goindex 1fe324d759..bd22a828da 100644--- a/store/data_source.go+++ b/store/data_source.go@@ -17,12 +17,6 @@ import (type dataSourceRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Related fieldsInstanceID intDatabaseID int@@ -47,12 +41,6 @@ func (raw *dataSourceRaw) toDataSource() *api.DataSource {return &api.DataSource{ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-// Related fieldsInstanceID: raw.InstanceID,DatabaseID: raw.DatabaseID,@@ -78,13 +66,9 @@ func (s *Store) CreateDataSource(ctx context.Context, instance *api.Instance, crif err != nil {return nil, errors.Wrapf(err, "failed to create data source with DataSourceCreate[%+v]", create)}- dataSource, err := s.composeDataSource(ctx, dataSourceRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose data source with dataSourceRaw[%+v]", dataSourceRaw)- }s.instanceCache.Delete(getInstanceCacheKey(instance.Environment.ResourceID, instance.ResourceID))s.instanceIDCache.Delete(instance.ID)- return dataSource, nil+ return composeDataSource(dataSourceRaw), nil}// GetDataSource gets an instance of DataSource.@@ -96,11 +80,7 @@ func (s *Store) GetDataSource(ctx context.Context, find *api.DataSourceFind) (*aif dataSourceRaw == nil {return nil, nil}- dataSource, err := s.composeDataSource(ctx, dataSourceRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose data source with dataSourceRaw[%+v]", dataSourceRaw)- }- return dataSource, nil+ return composeDataSource(dataSourceRaw), nil}// findDataSource finds a list of DataSource instances.@@ -112,11 +92,7 @@ func (s *Store) findDataSource(ctx context.Context, find *api.DataSourceFind) ([var dataSourceList []*api.DataSourcefor _, raw := range dataSourceRawList {- dataSource, err := s.composeDataSource(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose DataSource role with dataSourceRaw[%+v]", raw)- }- dataSourceList = append(dataSourceList, dataSource)+ dataSourceList = append(dataSourceList, composeDataSource(raw))}return dataSourceList, nil}@@ -127,13 +103,9 @@ func (s *Store) PatchDataSource(ctx context.Context, instance *api.Instance, patif err != nil {return nil, errors.Wrapf(err, "failed to patch DataSource with DataSourcePatch[%+v]", patch)}- dataSource, err := s.composeDataSource(ctx, dataSourceRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose DataSource role with dataSourceRaw[%+v]", dataSourceRaw)- }s.instanceCache.Delete(getInstanceCacheKey(instance.Environment.ResourceID, instance.ResourceID))s.instanceIDCache.Delete(instance.ID)- return dataSource, nil+ return composeDataSource(dataSourceRaw), nil}// DeleteDataSource deletes an existing dataSource by ID.@@ -174,22 +146,8 @@ func (s *Store) createDataSourceRawTx(ctx context.Context, tx *Tx, create *api.Dreturn nil}-func (s *Store) composeDataSource(ctx context.Context, raw *dataSourceRaw) (*api.DataSource, error) {- dataSource := raw.toDataSource()-- creator, err := s.GetPrincipalByID(ctx, dataSource.CreatorID)- if err != nil {- return nil, err- }- dataSource.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, dataSource.UpdaterID)- if err != nil {- return nil, err- }- dataSource.Updater = updater-- return dataSource, nil+func composeDataSource(raw *dataSourceRaw) *api.DataSource {+ return raw.toDataSource()}// createDataSourceRaw creates a new dataSource.@@ -313,7 +271,7 @@ func (*Store) createDataSourceImpl(ctx context.Context, tx *Tx, create *api.Datadatabase)VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)- RETURNING id, creator_id, created_ts, updater_id, updated_ts, instance_id, database_id, name, type, username, password, ssl_key, ssl_cert, ssl_ca, host, port, options, database+ RETURNING id, instance_id, database_id, name, type, username, password, ssl_key, ssl_cert, ssl_ca, host, port, options, database`var dataSourceRaw dataSourceRawif err := tx.QueryRowContext(ctx, query,@@ -334,10 +292,6 @@ func (*Store) createDataSourceImpl(ctx context.Context, tx *Tx, create *api.Datacreate.Database,).Scan(&dataSourceRaw.ID,- &dataSourceRaw.CreatorID,- &dataSourceRaw.CreatedTs,- &dataSourceRaw.UpdaterID,- &dataSourceRaw.UpdatedTs,&dataSourceRaw.InstanceID,&dataSourceRaw.DatabaseID,&dataSourceRaw.Name,@@ -379,10 +333,6 @@ func (*Store) findDataSourceImpl(ctx context.Context, tx *Tx, find *api.DataSourrows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,instance_id,database_id,name,@@ -411,10 +361,6 @@ func (*Store) findDataSourceImpl(ctx context.Context, tx *Tx, find *api.DataSourvar dataSourceRaw dataSourceRawif err := rows.Scan(&dataSourceRaw.ID,- &dataSourceRaw.CreatorID,- &dataSourceRaw.CreatedTs,- &dataSourceRaw.UpdaterID,- &dataSourceRaw.UpdatedTs,&dataSourceRaw.InstanceID,&dataSourceRaw.DatabaseID,&dataSourceRaw.Name,@@ -480,15 +426,11 @@ func (*Store) patchDataSourceImpl(ctx context.Context, tx *Tx, patch *api.DataSoUPDATE data_sourceSET `+strings.Join(set, ", ")+`WHERE id = $%d- RETURNING id, creator_id, created_ts, updater_id, updated_ts, instance_id, database_id, name, type, username, password, ssl_key, ssl_cert, ssl_ca, host, port, options, database+ RETURNING id, instance_id, database_id, name, type, username, password, ssl_key, ssl_cert, ssl_ca, host, port, options, database`, len(args)),args...,).Scan(&dataSourceRaw.ID,- &dataSourceRaw.CreatorID,- &dataSourceRaw.CreatedTs,- &dataSourceRaw.UpdaterID,- &dataSourceRaw.UpdatedTs,&dataSourceRaw.InstanceID,&dataSourceRaw.DatabaseID,&dataSourceRaw.Name,diff --git a/store/database.go b/store/database.goindex 2aa2d8d35f..7e22f24496 100644--- a/store/database.go+++ b/store/database.go@@ -179,8 +179,6 @@ func (s *Store) composeDatabase(ctx context.Context, database *DatabaseMessage)}composedDatabase := &api.Database{ID: database.UID,- CreatorID: api.SystemBotID,- UpdaterID: api.SystemBotID,ProjectID: project.UID,InstanceID: instance.UID,Name: database.DatabaseName,@@ -190,14 +188,6 @@ func (s *Store) composeDatabase(ctx context.Context, database *DatabaseMessage)SyncStatus: database.SyncState,LastSuccessfulSyncTs: database.SuccessfulSyncTimeTs,}-- bot, err := s.GetPrincipalByID(ctx, api.SystemBotID)- if err != nil {- return nil, err- }- composedDatabase.Creator = bot- composedDatabase.Updater = bot-composedProject, err := s.GetProjectByID(ctx, project.UID)if err != nil {return nil, errdiff --git a/store/deploy.go b/store/deploy.goindex 873dff7ca7..45c17f9c26 100644--- a/store/deploy.go+++ b/store/deploy.go@@ -18,12 +18,6 @@ import (type deploymentConfigRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Related fieldsProjectID int@@ -38,12 +32,6 @@ func (raw *deploymentConfigRaw) toDeploymentConfig() *api.DeploymentConfig {return &api.DeploymentConfig{ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-// Related fieldsProjectID: raw.ProjectID,@@ -98,8 +86,6 @@ func (s *Store) getDefaultDeploymentConfig(ctx context.Context, projectID int) (}return &deploymentConfigRaw{ID: 0,- CreatorID: api.SystemBotID,- UpdaterID: api.SystemBotID,ProjectID: projectID,Payload: string(bytes),}, nil@@ -124,25 +110,11 @@ func (s *Store) UpsertDeploymentConfig(ctx context.Context, upsert *api.Deploymefunc (s *Store) composeDeploymentConfig(ctx context.Context, raw *deploymentConfigRaw) (*api.DeploymentConfig, error) {deploymentConfig := raw.toDeploymentConfig()-- creator, err := s.GetPrincipalByID(ctx, deploymentConfig.CreatorID)- if err != nil {- return nil, err- }- deploymentConfig.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, deploymentConfig.UpdaterID)- if err != nil {- return nil, err- }- deploymentConfig.Updater = updater-project, err := s.GetProjectByID(ctx, deploymentConfig.ProjectID)if err != nil {return nil, err}deploymentConfig.Project = project-return deploymentConfig, nil}@@ -191,10 +163,6 @@ func (s *Store) getDeploymentConfigImpl(ctx context.Context, find *api.Deploymenrows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,project_id,name,config@@ -213,10 +181,6 @@ func (s *Store) getDeploymentConfigImpl(ctx context.Context, find *api.Deploymenvar cfg deploymentConfigRawif err := rows.Scan(&cfg.ID,- &cfg.CreatorID,- &cfg.CreatedTs,- &cfg.UpdaterID,- &cfg.UpdatedTs,&cfg.ProjectID,&cfg.Name,&cfg.Payload,@@ -254,11 +218,10 @@ func (*Store) upsertDeploymentConfigImpl(ctx context.Context, tx *Tx, upsert *ap)VALUES ($1, $2, $3, $4, $5)ON CONFLICT(project_id) DO UPDATE SET- creator_id = excluded.creator_id,updater_id = excluded.updater_id,name = excluded.name,config = excluded.config- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, name, config+ RETURNING id, project_id, name, config`var cfg deploymentConfigRawif err := tx.QueryRowContext(ctx, query,@@ -269,10 +232,6 @@ func (*Store) upsertDeploymentConfigImpl(ctx context.Context, tx *Tx, upsert *apupsert.Payload,).Scan(&cfg.ID,- &cfg.CreatorID,- &cfg.CreatedTs,- &cfg.UpdaterID,- &cfg.UpdatedTs,&cfg.ProjectID,&cfg.Name,&cfg.Payload,diff --git a/store/instance.go b/store/instance.goindex 8726cebf6c..2a1f9fbc89 100644--- a/store/instance.go+++ b/store/instance.go@@ -329,15 +329,6 @@ func (s *Store) composeInstance(ctx context.Context, raw *instanceRaw) (*api.Insreturn nil, err}instance.DataSourceList = dataSourceList- for _, dataSource := range instance.DataSourceList {- if dataSource.Creator, err = s.GetPrincipalByID(ctx, dataSource.CreatorID); err != nil {- return nil, err- }- if dataSource.Updater, err = s.GetPrincipalByID(ctx, dataSource.UpdaterID); err != nil {- return nil, err- }- }-return instance, nil}diff --git a/store/principal.go b/store/principal.goindex c3b47eb8ab..43d8b5750d 100644--- a/store/principal.go+++ b/store/principal.go@@ -52,12 +52,10 @@ func (s *Store) GetPrincipalByID(ctx context.Context, id int) (*api.Principal, e// composePrincipal composes an instance of Principal by principalRaw.func composePrincipal(user *UserMessage) (*api.Principal, error) {principal := &api.Principal{- ID: user.ID,- CreatorID: api.SystemBotID,- UpdaterID: api.SystemBotID,- Type: user.Type,- Name: user.Name,- Email: user.Email,+ ID: user.ID,+ Type: user.Type,+ Name: user.Name,+ Email: user.Email,// Do not return to the client.PasswordHash: user.PasswordHash,Role: user.Role,diff --git a/store/project_webhook.go b/store/project_webhook.goindex 3ca3ad1793..e34c8991de 100644--- a/store/project_webhook.go+++ b/store/project_webhook.go@@ -18,12 +18,6 @@ import (type projectWebhookRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Related fieldsProjectID int@@ -40,12 +34,6 @@ func (raw *projectWebhookRaw) toProjectWebhook() *api.ProjectWebhook {projectWebhook := api.ProjectWebhook{ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-// Related fieldsProjectID: raw.ProjectID,@@ -64,11 +52,7 @@ func (s *Store) CreateProjectWebhook(ctx context.Context, create *api.ProjectWebif err != nil {return nil, errors.Wrapf(err, "failed to create ProjectWebhook with ProjectWebhookCreate[%+v]", create)}- projectWebhook, err := s.composeProjectWebhook(ctx, projectWebhookRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose ProjectWebhook with projectWebhookRaw[%+v]", projectWebhookRaw)- }- return projectWebhook, nil+ return composeProjectWebhook(projectWebhookRaw), nil}// GetProjectWebhookByID gets an instance of ProjectWebhook.@@ -81,11 +65,7 @@ func (s *Store) GetProjectWebhookByID(ctx context.Context, id int) (*api.Projectif projectWebhookRaw == nil {return nil, nil}- projectWebhook, err := s.composeProjectWebhook(ctx, projectWebhookRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose ProjectWebhook with projectWebhookRaw[%+v]", projectWebhookRaw)- }- return projectWebhook, nil+ return composeProjectWebhook(projectWebhookRaw), nil}// FindProjectWebhook finds a list of ProjectWebhook instances.@@ -96,11 +76,7 @@ func (s *Store) FindProjectWebhook(ctx context.Context, find *api.ProjectWebhook}var projectWebhookList []*api.ProjectWebhookfor _, raw := range projectWebhookRawList {- projectWebhook, err := s.composeProjectWebhook(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose ProjectWebhook with projectWebhookRaw[%+v]", raw)- }- projectWebhookList = append(projectWebhookList, projectWebhook)+ projectWebhookList = append(projectWebhookList, composeProjectWebhook(raw))}return projectWebhookList, nil}@@ -111,11 +87,7 @@ func (s *Store) PatchProjectWebhook(ctx context.Context, patch *api.ProjectWebhoif err != nil {return nil, errors.Wrapf(err, "failed to patch ProjectWebhook with ProjectWebhookPatch[%+v]", patch)}- projectWebhook, err := s.composeProjectWebhook(ctx, projectWebhookRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose ProjectWebhook with projectWebhookRaw[%+v]", projectWebhookRaw)- }- return projectWebhook, nil+ return composeProjectWebhook(projectWebhookRaw), nil}// DeleteProjectWebhook deletes an existing projectWebhook by ID.@@ -141,22 +113,8 @@ func (s *Store) DeleteProjectWebhook(ctx context.Context, delete *api.ProjectWeb// private functions//-func (s *Store) composeProjectWebhook(ctx context.Context, raw *projectWebhookRaw) (*api.ProjectWebhook, error) {- webhook := raw.toProjectWebhook()-- creator, err := s.GetPrincipalByID(ctx, webhook.CreatorID)- if err != nil {- return nil, err- }- webhook.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, webhook.UpdaterID)- if err != nil {- return nil, err- }- webhook.Updater = updater-- return webhook, nil+func composeProjectWebhook(raw *projectWebhookRaw) *api.ProjectWebhook {+ return raw.toProjectWebhook()}// createProjectWebhookRaw creates a new projectWebhook.@@ -252,7 +210,7 @@ func createProjectWebhookImpl(ctx context.Context, tx *Tx, create *api.ProjectWeactivity_list)VALUES ($1, $2, $3, $4, $5, $6, $7)- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, type, name, url, activity_list+ RETURNING id, project_id, type, name, url, activity_list`var projectWebhookRaw projectWebhookRawvar txtArray pgtype.TextArray@@ -266,10 +224,6 @@ func createProjectWebhookImpl(ctx context.Context, tx *Tx, create *api.ProjectWecreate.ActivityList,).Scan(&projectWebhookRaw.ID,- &projectWebhookRaw.CreatorID,- &projectWebhookRaw.CreatedTs,- &projectWebhookRaw.UpdaterID,- &projectWebhookRaw.UpdatedTs,&projectWebhookRaw.ProjectID,&projectWebhookRaw.Type,&projectWebhookRaw.Name,@@ -300,10 +254,6 @@ func findProjectWebhookImpl(ctx context.Context, tx *Tx, find *api.ProjectWebhoorows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,project_id,type,name,@@ -326,10 +276,6 @@ func findProjectWebhookImpl(ctx context.Context, tx *Tx, find *api.ProjectWebhooif err := rows.Scan(&projectWebhookRaw.ID,- &projectWebhookRaw.CreatorID,- &projectWebhookRaw.CreatedTs,- &projectWebhookRaw.UpdaterID,- &projectWebhookRaw.UpdatedTs,&projectWebhookRaw.ProjectID,&projectWebhookRaw.Type,&projectWebhookRaw.Name,@@ -385,15 +331,11 @@ func patchProjectWebhookImpl(ctx context.Context, tx *Tx, patch *api.ProjectWebhUPDATE project_webhookSET `+strings.Join(set, ", ")+`WHERE id = $%d- RETURNING id, creator_id, created_ts, updater_id, updated_ts, project_id, type, name, url, activity_list+ RETURNING id, project_id, type, name, url, activity_list`, len(args)),args...,).Scan(&projectWebhookRaw.ID,- &projectWebhookRaw.CreatorID,- &projectWebhookRaw.CreatedTs,- &projectWebhookRaw.UpdaterID,- &projectWebhookRaw.UpdatedTs,&projectWebhookRaw.ProjectID,&projectWebhookRaw.Type,&projectWebhookRaw.Name,diff --git a/store/repository.go b/store/repository.goindex a3faa84915..0379b6e026 100644--- a/store/repository.go+++ b/store/repository.go@@ -17,12 +17,6 @@ import (type repositoryRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Related fieldsVCSID intProjectID int@@ -53,11 +47,6 @@ func (raw *repositoryRaw) toRepository() *api.Repository {return &api.Repository{ID: raw.ID,- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-VCSID: raw.VCSID,ProjectID: raw.ProjectID,@@ -166,18 +155,6 @@ func (s *Store) DeleteRepository(ctx context.Context, delete *api.RepositoryDelefunc (s *Store) composeRepository(ctx context.Context, raw *repositoryRaw) (*api.Repository, error) {repository := raw.toRepository()- creator, err := s.GetPrincipalByID(ctx, repository.CreatorID)- if err != nil {- return nil, err- }- repository.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, repository.UpdaterID)- if err != nil {- return nil, err- }- repository.Updater = updater-vcs, err := s.GetVCSByID(ctx, repository.VCSID)if err != nil {return nil, err@@ -319,7 +296,7 @@ func (s *Store) createRepositoryImpl(ctx context.Context, tx *Tx, create *api.Rerefresh_token)VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21)- RETURNING id, creator_id, created_ts, updater_id, updated_ts, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token+ RETURNING id, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token`if err := tx.QueryRowContext(ctx, query,create.CreatorID,@@ -345,10 +322,6 @@ func (s *Store) createRepositoryImpl(ctx context.Context, tx *Tx, create *api.Recreate.RefreshToken,).Scan(&repository.ID,- &repository.CreatorID,- &repository.CreatedTs,- &repository.UpdaterID,- &repository.UpdatedTs,&repository.VCSID,&repository.ProjectID,&repository.Name,@@ -399,10 +372,6 @@ func (*Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Repositorows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,vcs_id,project_id,name,@@ -437,10 +406,6 @@ func (*Store) findRepositoryImpl(ctx context.Context, tx *Tx, find *api.Repositovar repository repositoryRawif err := rows.Scan(&repository.ID,- &repository.CreatorID,- &repository.CreatedTs,- &repository.UpdaterID,- &repository.UpdatedTs,&repository.VCSID,&repository.ProjectID,&repository.Name,@@ -521,15 +486,11 @@ func (*Store) patchRepositoryImpl(ctx context.Context, tx *Tx, patch *api.ReposiUPDATE repositorySET `+strings.Join(set, ", ")+`WHERE `+strings.Join(where, " AND ")+`- RETURNING id, creator_id, created_ts, updater_id, updated_ts, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token+ RETURNING id, vcs_id, project_id, name, full_path, web_url, branch_filter, base_directory, file_path_template, schema_path_template, sheet_path_template, enable_sql_review_ci, external_id, external_webhook_id, webhook_url_host, webhook_endpoint_id, webhook_secret_token, access_token, expires_ts, refresh_token`,args...,).Scan(&repository.ID,- &repository.CreatorID,- &repository.CreatedTs,- &repository.UpdaterID,- &repository.UpdatedTs,&repository.VCSID,&repository.ProjectID,&repository.Name,diff --git a/store/setting.go b/store/setting.goindex 5e68e71064..061efe3a13 100644--- a/store/setting.go+++ b/store/setting.go@@ -16,12 +16,6 @@ import (type settingRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Domain specific fieldsName api.SettingNameValue string@@ -34,12 +28,6 @@ func (raw *settingRaw) toSetting() *api.Setting {return &api.Setting{ID: raw.ID,- // Standard fields- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-// Domain specific fieldsName: raw.Name,Value: raw.Value,@@ -53,11 +41,7 @@ func (s *Store) CreateSettingIfNotExist(ctx context.Context, create *api.Settingif err != nil {return nil, false, errors.Wrapf(err, "failed to create Setting with SettingCreate[%+v]", create)}- setting, err := s.composeSetting(ctx, settingRaw)- if err != nil {- return nil, false, errors.Wrapf(err, "failed to compose Setting with settingRaw[%+v]", settingRaw)- }- return setting, created, nil+ return settingRaw.toSetting(), created, nil}// FindSetting finds a list of Setting instances.@@ -68,11 +52,7 @@ func (s *Store) FindSetting(ctx context.Context, find *api.SettingFind) ([]*api.}var settingList []*api.Settingfor _, raw := range settingRawList {- setting, err := s.composeSetting(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Setting with settingRaw[%+v]", raw)- }- settingList = append(settingList, setting)+ settingList = append(settingList, raw.toSetting())}return settingList, nil}@@ -86,11 +66,7 @@ func (s *Store) GetSetting(ctx context.Context, find *api.SettingFind) (*api.Setif settingRaw == nil {return nil, nil}- setting, err := s.composeSetting(ctx, settingRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Setting with settingRaw[%+v]", settingRaw)- }- return setting, nil+ return settingRaw.toSetting(), nil}// PatchSetting patches an instance of Setting.@@ -99,35 +75,13 @@ func (s *Store) PatchSetting(ctx context.Context, patch *api.SettingPatch) (*apiif err != nil {return nil, errors.Wrapf(err, "failed to patch Setting with SettingPatch[%+v]", patch)}- setting, err := s.composeSetting(ctx, settingRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose Setting with settingRaw[%+v]", settingRaw)- }- return setting, nil+ return settingRaw.toSetting(), nil}//// private functions//-func (s *Store) composeSetting(ctx context.Context, raw *settingRaw) (*api.Setting, error) {- setting := raw.toSetting()-- creator, err := s.GetPrincipalByID(ctx, setting.CreatorID)- if err != nil {- return nil, err- }- setting.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, setting.UpdaterID)- if err != nil {- return nil, err- }- setting.Updater = updater-- return setting, nil-}-// createSettingRawIfNotExist creates a new setting only if the named setting does not exist.// The returned bool means the resource is created successfully.func (s *Store) createSettingRawIfNotExist(ctx context.Context, create *api.SettingCreate) (*settingRaw, bool, error) {@@ -264,10 +218,6 @@ func findSettingImpl(ctx context.Context, tx *Tx, find *api.SettingFind) ([]*setrows, err := tx.QueryContext(ctx, `SELECT- creator_id,- created_ts,- updater_id,- updated_ts,name,value,description@@ -285,10 +235,6 @@ func findSettingImpl(ctx context.Context, tx *Tx, find *api.SettingFind) ([]*setfor rows.Next() {var settingRaw settingRawif err := rows.Scan(- &settingRaw.CreatorID,- &settingRaw.CreatedTs,- &settingRaw.UpdaterID,- &settingRaw.UpdatedTs,&settingRaw.Name,&settingRaw.Value,&settingRaw.Description,@@ -319,14 +265,10 @@ func patchSettingImpl(ctx context.Context, tx *Tx, patch *api.SettingPatch) (*seUPDATE settingSET `+strings.Join(set, ", ")+`WHERE name = $3- RETURNING creator_id, created_ts, updater_id, updated_ts, name, value, description+ RETURNING name, value, description`,args...,).Scan(- &settingRaw.CreatorID,- &settingRaw.CreatedTs,- &settingRaw.UpdaterID,- &settingRaw.UpdatedTs,&settingRaw.Name,&settingRaw.Value,&settingRaw.Description,diff --git a/store/vcs.go b/store/vcs.goindex e786b71d08..3915fb7e8c 100644--- a/store/vcs.go+++ b/store/vcs.go@@ -18,12 +18,6 @@ import (type vcsRaw struct {ID int- // Standard fields- CreatorID int- CreatedTs int64- UpdaterID int- UpdatedTs int64-// Domain specific fieldsName stringType vcs.Type@@ -39,11 +33,6 @@ func (raw *vcsRaw) toVCS() *api.VCS {return &api.VCS{ID: raw.ID,- CreatorID: raw.CreatorID,- CreatedTs: raw.CreatedTs,- UpdaterID: raw.UpdaterID,- UpdatedTs: raw.UpdatedTs,-Name: raw.Name,Type: raw.Type,InstanceURL: raw.InstanceURL,@@ -59,11 +48,7 @@ func (s *Store) CreateVCS(ctx context.Context, create *api.VCSCreate) (*api.VCS,if err != nil {return nil, errors.Wrapf(err, "failed to create VCS with VCSCreate[%+v]", create)}- vcs, err := s.composeVCS(ctx, vcsRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose VCS with vcsRaw[%+v]", vcsRaw)- }- return vcs, nil+ return vcsRaw.toVCS(), nil}// FindVCS finds a list of VCS instances.@@ -74,11 +59,7 @@ func (s *Store) FindVCS(ctx context.Context, find *api.VCSFind) ([]*api.VCS, err}var vcsList []*api.VCSfor _, raw := range vcsRawList {- vcs, err := s.composeVCS(ctx, raw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose VCS with vcsRaw[%+v]", raw)- }- vcsList = append(vcsList, vcs)+ vcsList = append(vcsList, raw.toVCS())}return vcsList, nil}@@ -92,12 +73,7 @@ func (s *Store) GetVCSByID(ctx context.Context, id int) (*api.VCS, error) {if vcsRaw == nil {return nil, nil}-- vcs, err := s.composeVCS(ctx, vcsRaw)- if err != nil {- return nil, err- }- return vcs, nil+ return vcsRaw.toVCS(), nil}// PatchVCS patches an instance of VCS.@@ -106,11 +82,7 @@ func (s *Store) PatchVCS(ctx context.Context, patch *api.VCSPatch) (*api.VCS, erif err != nil {return nil, errors.Wrapf(err, "failed to patch VCS with VCSPatch[%+v]", patch)}- vcs, err := s.composeVCS(ctx, vcsRaw)- if err != nil {- return nil, errors.Wrapf(err, "failed to compose VCS with vcsRaw[%+v]", vcsRaw)- }- return vcs, nil+ return vcsRaw.toVCS(), nil}// DeleteVCS deletes an instance of VCS.@@ -125,24 +97,6 @@ func (s *Store) DeleteVCS(ctx context.Context, delete *api.VCSDelete) error {// private functions//-func (s *Store) composeVCS(ctx context.Context, raw *vcsRaw) (*api.VCS, error) {- vcs := raw.toVCS()-- creator, err := s.GetPrincipalByID(ctx, vcs.CreatorID)- if err != nil {- return nil, err- }- vcs.Creator = creator-- updater, err := s.GetPrincipalByID(ctx, vcs.UpdaterID)- if err != nil {- return nil, err- }- vcs.Updater = updater-- return vcs, nil-}-// createVCSRaw creates a new vcs.func (s *Store) createVCSRaw(ctx context.Context, create *api.VCSCreate) (*vcsRaw, error) {tx, err := s.db.BeginTx(ctx, nil)@@ -263,7 +217,7 @@ func createVCSImpl(ctx context.Context, tx *Tx, create *api.VCSCreate) (*vcsRaw,secret)VALUES ($1, $2, $3, $4, $5, $6, $7, $8)- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, type, instance_url, api_url, application_id, secret+ RETURNING id, name, type, instance_url, api_url, application_id, secret`var vcs vcsRawif err := tx.QueryRowContext(ctx, query,@@ -277,10 +231,6 @@ func createVCSImpl(ctx context.Context, tx *Tx, create *api.VCSCreate) (*vcsRaw,create.Secret,).Scan(&vcs.ID,- &vcs.CreatorID,- &vcs.CreatedTs,- &vcs.UpdaterID,- &vcs.UpdatedTs,&vcs.Name,&vcs.Type,&vcs.InstanceURL,@@ -306,10 +256,6 @@ func findVCSImpl(ctx context.Context, tx *Tx, find *api.VCSFind) ([]*vcsRaw, errrows, err := tx.QueryContext(ctx, `SELECTid,- creator_id,- created_ts,- updater_id,- updated_ts,name,type,instance_url,@@ -331,10 +277,6 @@ func findVCSImpl(ctx context.Context, tx *Tx, find *api.VCSFind) ([]*vcsRaw, errvar vcs vcsRawif err := rows.Scan(&vcs.ID,- &vcs.CreatorID,- &vcs.CreatedTs,- &vcs.UpdaterID,- &vcs.UpdatedTs,&vcs.Name,&vcs.Type,&vcs.InstanceURL,@@ -375,15 +317,11 @@ func patchVCSImpl(ctx context.Context, tx *Tx, patch *api.VCSPatch) (*vcsRaw, erUPDATE vcsSET `+strings.Join(set, ", ")+`WHERE id = $%d- RETURNING id, creator_id, created_ts, updater_id, updated_ts, name, type, instance_url, api_url, application_id, secret+ RETURNING id, name, type, instance_url, api_url, application_id, secret`, len(args)),args...,).Scan(&vcs.ID,- &vcs.CreatorID,- &vcs.CreatedTs,- &vcs.UpdaterID,- &vcs.UpdatedTs,&vcs.Name,&vcs.Type,&vcs.InstanceURL,