Skip to content

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

chore: remove unused creator/updater from backup,bookmark,environment,instance,project (#4203)

Danny Xuf3c0054aaedb
diff --git a/api/backup.go b/api/backup.go
index 0009b008c3..6a8f567c7b 100644
--- a/api/backup.go
+++ b/api/backup.go
@@ -77,12 +77,8 @@ type Backup struct {
// Standard fields
RowStatus RowStatus `jsonapi:"attr,rowStatus"`
- CreatorID int
- Creator *Principal `jsonapi:"relation,creator"`
- CreatedTs int64 `jsonapi:"attr,createdTs"`
- UpdaterID int
- Updater *Principal `jsonapi:"relation,updater"`
- UpdatedTs int64 `jsonapi:"attr,updatedTs"`
+ CreatedTs int64 `jsonapi:"attr,createdTs"`
+ UpdatedTs int64 `jsonapi:"attr,updatedTs"`
// Related fields
DatabaseID int `jsonapi:"attr,databaseId"`
diff --git a/api/bookmark.go b/api/bookmark.go
index 24a3900fce..49b32b7d0c 100644
--- a/api/bookmark.go
+++ b/api/bookmark.go
@@ -11,10 +11,6 @@ type Bookmark struct {
// 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 fields
Name string `jsonapi:"attr,name"`
diff --git a/api/environment.go b/api/environment.go
index 471c8f2aa7..06e14163e4 100644
--- a/api/environment.go
+++ b/api/environment.go
@@ -8,17 +8,17 @@ import (
// Environment is the API message for an environment.
type Environment struct {
- ID int `jsonapi:"primary,environment"`
- ResourceID string
+ ID int `jsonapi:"primary,environment"`
+ ResourceID string `jsonapi:"attr,resourceId"`
// Standard fields
RowStatus RowStatus `jsonapi:"attr,rowStatus"`
CreatorID int
- Creator *Principal `jsonapi:"relation,creator"`
- CreatedTs int64 `jsonapi:"attr,createdTs"`
+ Creator *Principal
+ CreatedTs int64
UpdaterID int
- Updater *Principal `jsonapi:"relation,updater"`
- UpdatedTs int64 `jsonapi:"attr,updatedTs"`
+ Updater *Principal
+ UpdatedTs int64
// Domain specific fields
Name string `jsonapi:"attr,name"`
diff --git a/api/instance.go b/api/instance.go
index 1e06cd0bea..cc68096af3 100644
--- a/api/instance.go
+++ b/api/instance.go
@@ -8,17 +8,9 @@ import (
// Instance is the API message for an instance.
type Instance struct {
- ID int `jsonapi:"primary,instance"`
- ResourceID string
-
- // Standard fields
- RowStatus RowStatus `jsonapi:"attr,rowStatus"`
- CreatorID int
- Creator *Principal `jsonapi:"relation,creator"`
- CreatedTs int64 `jsonapi:"attr,createdTs"`
- UpdaterID int
- Updater *Principal `jsonapi:"relation,updater"`
- UpdatedTs int64 `jsonapi:"attr,updatedTs"`
+ ID int `jsonapi:"primary,instance"`
+ ResourceID string `jsonapi:"attr,resourceId"`
+ RowStatus RowStatus `jsonapi:"attr,rowStatus"`
// Related fields
EnvironmentID int
diff --git a/api/member.go b/api/member.go
index fa98f1bb0d..f74d584120 100644
--- a/api/member.go
+++ b/api/member.go
@@ -1,9 +1,5 @@
package api
-import (
- "encoding/json"
-)
-
// MemberStatus is the status of an member.
type MemberStatus string
@@ -34,14 +30,7 @@ const (
type Member struct {
ID int `jsonapi:"primary,member"`
- // Standard fields
RowStatus RowStatus `jsonapi:"attr,rowStatus"`
- 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 fields
Status MemberStatus `jsonapi:"attr,status"`
@@ -52,31 +41,9 @@ type Member struct {
// MemberCreate is the API message for creating a member.
type MemberCreate struct {
- // Standard fields
- // Value is assigned from the jwt subject field passed by the client.
- CreatorID int
-
- // Domain specific fields
- Status MemberStatus `jsonapi:"attr,status"`
- Role Role `jsonapi:"attr,role"`
- PrincipalID int `jsonapi:"attr,principalId"`
-}
-
-// MemberFind is the API message for finding members.
-type MemberFind struct {
- ID *int
-
// Domain specific fields
- PrincipalID *int
- Role *Role
-}
-
-func (find *MemberFind) String() string {
- str, err := json.Marshal(*find)
- if err != nil {
- return err.Error()
- }
- return string(str)
+ Role Role `jsonapi:"attr,role"`
+ PrincipalID int `jsonapi:"attr,principalId"`
}
// MemberPatch is the API message for patching a member.
@@ -85,9 +52,6 @@ type MemberPatch struct {
// Standard fields
RowStatus *string `jsonapi:"attr,rowStatus"`
- // Value is assigned from the jwt subject field passed by the client.
- UpdaterID int
-
// Domain specific fields
Role *string `jsonapi:"attr,role"`
}
diff --git a/api/project.go b/api/project.go
index 3bb4d4d509..b81041d1a8 100644
--- a/api/project.go
+++ b/api/project.go
@@ -57,17 +57,9 @@ const (
// Project is the API message for a project.
type Project struct {
- ID int `jsonapi:"primary,project"`
- ResourceID string
-
- // Standard fields
- RowStatus RowStatus `jsonapi:"attr,rowStatus"`
- CreatorID int
- Creator *Principal `jsonapi:"relation,creator"`
- CreatedTs int64 `jsonapi:"attr,createdTs"`
- UpdaterID int
- Updater *Principal `jsonapi:"relation,updater"`
- UpdatedTs int64 `jsonapi:"attr,updatedTs"`
+ ID int `jsonapi:"primary,project"`
+ ResourceID string `jsonapi:"attr,resourceId"`
+ RowStatus RowStatus `jsonapi:"attr,rowStatus"`
// Related fields
ProjectMemberList []*ProjectMember `jsonapi:"relation,projectMember"`
diff --git a/frontend/src/components/InstanceTable.vue b/frontend/src/components/InstanceTable.vue
index 091b20833d..34c499e95a 100644
--- a/frontend/src/components/InstanceTable.vue
+++ b/frontend/src/components/InstanceTable.vue
@@ -27,14 +27,11 @@
<button
v-if="instance.externalLink?.trim().length != 0"
class="btn-icon"
- @click.stop="window.open(urlfy(instanceLink(instance)), '_blank')"
+ @click.stop="window.open(urlfy(instance.externalLink), '_blank')"
>
<heroicons-outline:external-link class="w-4 h-4" />
</button>
</div>
- <div class="bb-grid-cell">
- {{ humanizeTs(instance.createdTs) }}
- </div>
</template>
</BBGrid>
</template>
@@ -87,10 +84,6 @@ export default defineComponent({
width: { sm: "1fr" },
class: "hidden sm:flex",
},
- {
- title: t("common.created-at"),
- width: "minmax(auto, 8rem)",
- },
];
});
@@ -113,23 +106,11 @@ export default defineComponent({
return environmentName(env);
};
- const instanceLink = (instance: Instance): string => {
- if (instance.engine == "SNOWFLAKE") {
- if (instance.host) {
- return `https://${
- instance.host.split("@")[0]
- }.snowflakecomputing.com/console`;
- }
- }
- return instance.host;
- };
-
return {
columnList,
urlfy,
clickInstance,
environmentNameFromId,
- instanceLink,
};
},
});
diff --git a/frontend/src/store/modules/backup.ts b/frontend/src/store/modules/backup.ts
index 0b40b10ed9..e697f36c4a 100644
--- a/frontend/src/store/modules/backup.ts
+++ b/frontend/src/store/modules/backup.ts
@@ -21,16 +21,8 @@ export function convertBackup(
includedList: ResourceObject[]
): Backup {
return {
- ...(backup.attributes as Omit<Backup, "id" | "creator" | "updater">),
+ ...(backup.attributes as Omit<Backup, "id">),
id: parseInt(backup.id),
- creator: getPrincipalFromIncludedList(
- backup.relationships!.creator.data,
- includedList
- ),
- updater: getPrincipalFromIncludedList(
- backup.relationships!.updater.data,
- includedList
- ),
};
}
diff --git a/frontend/src/store/modules/bookmark.ts b/frontend/src/store/modules/bookmark.ts
index 9af927f624..5bf4943a26 100644
--- a/frontend/src/store/modules/bookmark.ts
+++ b/frontend/src/store/modules/bookmark.ts
@@ -15,16 +15,12 @@ function convert(
includedList: ResourceObject[]
): Bookmark {
return {
- ...(bookmark.attributes as Omit<Bookmark, "id" | "creator" | "updater">),
+ ...(bookmark.attributes as Omit<Bookmark, "id" | "creator">),
id: parseInt(bookmark.id),
creator: getPrincipalFromIncludedList(
bookmark.relationships!.creator.data,
includedList
),
- updater: getPrincipalFromIncludedList(
- bookmark.relationships!.updater.data,
- includedList
- ),
};
}
diff --git a/frontend/src/store/modules/environment.ts b/frontend/src/store/modules/environment.ts
index 3d375d98fa..1ae2de32b8 100644
--- a/frontend/src/store/modules/environment.ts
+++ b/frontend/src/store/modules/environment.ts
@@ -14,7 +14,6 @@ import {
unknown,
} from "@/types";
import { usePolicyStore } from "./policy";
-import { getPrincipalFromIncludedList } from "./principal";
import { environmentName } from "../../utils";
function convert(
@@ -22,19 +21,8 @@ function convert(
includedList: ResourceObject[]
): Environment {
return {
- ...(environment.attributes as Omit<
- Environment,
- "id" | "creator" | "updater"
- >),
+ ...(environment.attributes as Omit<Environment, "id">),
id: parseInt(environment.id),
- creator: getPrincipalFromIncludedList(
- environment.relationships!.creator.data,
- includedList
- ),
- updater: getPrincipalFromIncludedList(
- environment.relationships!.updater.data,
- includedList
- ),
};
}
diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.ts
index 6029abca85..d08e600da6 100644
--- a/frontend/src/store/modules/instance.ts
+++ b/frontend/src/store/modules/instance.ts
@@ -26,7 +26,6 @@ import {
UNKNOWN_ID,
} from "@/types";
import { InstanceUser } from "@/types/InstanceUser";
-import { getPrincipalFromIncludedList } from "./principal";
import { useEnvironmentStore } from "./environment";
import { useDataSourceStore } from "./dataSource";
import { useSQLStore } from "./sql";
@@ -53,17 +52,9 @@ function convert(
const instancePartial = {
...(instance.attributes as Omit<
Instance,
- "id" | "environment" | "dataSourceList" | "creator" | "updater"
+ "id" | "environment" | "dataSourceList"
>),
id: parseInt(instance.id),
- creator: getPrincipalFromIncludedList(
- instance.relationships!.creator.data,
- includedList
- ),
- updater: getPrincipalFromIncludedList(
- instance.relationships!.updater.data,
- includedList
- ),
environment,
dataSourceList: [],
};
@@ -148,7 +139,7 @@ export const useInstanceStore = defineStore("instance", {
}
}
return list.sort((a: Instance, b: Instance) => {
- return b.createdTs - a.createdTs;
+ return b.id - a.id;
});
},
getInstanceListByEnvironmentId(
diff --git a/frontend/src/store/modules/member.ts b/frontend/src/store/modules/member.ts
index d08a65f5b4..789e062ea3 100644
--- a/frontend/src/store/modules/member.ts
+++ b/frontend/src/store/modules/member.ts
@@ -28,19 +28,8 @@ function convert(
principal.role = member.attributes.role as RoleType;
return {
- ...(member.attributes as Omit<
- Member,
- "id" | "principal" | "creator" | "updater"
- >),
+ ...(member.attributes as Omit<Member, "id" | "principal">),
id: parseInt(member.id),
- creator: getPrincipalFromIncludedList(
- member.relationships!.creator.data,
- includedList
- ),
- updater: getPrincipalFromIncludedList(
- member.relationships!.updater.data,
- includedList
- ),
principal: principal,
};
}
@@ -101,10 +90,7 @@ export const useMemberStore = defineStore("member", {
// sort the member list
memberList.sort((a: Member, b: Member) => {
- if (a.createdTs === b.createdTs) {
- return a.id - b.id;
- }
- return a.createdTs - b.createdTs;
+ return a.id - b.id;
});
this.setMemberList(memberList);
diff --git a/frontend/src/store/modules/project.ts b/frontend/src/store/modules/project.ts
index 886543b879..a65bd9332a 100644
--- a/frontend/src/store/modules/project.ts
+++ b/frontend/src/store/modules/project.ts
@@ -24,27 +24,15 @@ function convert(
project: ResourceObject,
includedList: ResourceObject[]
): Project {
- const attrs = project.attributes as Omit<
- Project,
- "id" | "memberList" | "creator" | "updater"
- >;
+ const attrs = project.attributes as Omit<Project, "id" | "memberList">;
// Only able to assign an empty member list, otherwise would cause circular dependency.
// This should be fine as we shouldn't access member via member.project.memberList
const projectWithoutMemberList: Project = {
id: parseInt(project.id),
+ resourceId: attrs.resourceId,
rowStatus: attrs.rowStatus,
name: attrs.name,
key: attrs.key,
- creator: getPrincipalFromIncludedList(
- project.relationships!.creator.data,
- includedList
- ),
- updater: getPrincipalFromIncludedList(
- project.relationships!.updater.data,
- includedList
- ),
- createdTs: attrs.createdTs,
- updatedTs: attrs.updatedTs,
memberList: [],
workflowType: attrs.workflowType,
visibility: attrs.visibility,
diff --git a/frontend/src/types/backup.ts b/frontend/src/types/backup.ts
index 63c2efee6b..10ae3e5367 100644
--- a/frontend/src/types/backup.ts
+++ b/frontend/src/types/backup.ts
@@ -15,10 +15,7 @@ export type Backup = {
databaseId: DatabaseId;
// Standard fields
- creator: Principal;
createdTs: number;
- updater: Principal;
- updatedTs: number;
name: string;
status: BackupStatus;
diff --git a/frontend/src/types/bookmark.ts b/frontend/src/types/bookmark.ts
index 03ec18ced4..68af722d22 100644
--- a/frontend/src/types/bookmark.ts
+++ b/frontend/src/types/bookmark.ts
@@ -6,9 +6,6 @@ export type Bookmark = {
// Standard fields
creator: Principal;
- createdTs: number;
- updater: Principal;
- updatedTs: number;
// Domain specific fields
name: string;
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index 929ddce839..0adde0de73 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -179,10 +179,6 @@ const makeUnknown = (type: ResourceType) => {
const UNKNOWN_MEMBER: Member = {
id: UNKNOWN_ID,
rowStatus: "NORMAL",
- creator: UNKNOWN_PRINCIPAL,
- updater: UNKNOWN_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
status: "ACTIVE",
role: "DEVELOPER",
principal: UNKNOWN_PRINCIPAL,
@@ -190,10 +186,7 @@ const makeUnknown = (type: ResourceType) => {
const UNKNOWN_ENVIRONMENT: Environment = {
id: UNKNOWN_ID,
- creator: UNKNOWN_PRINCIPAL,
- updater: UNKNOWN_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
+ resourceId: "",
rowStatus: "NORMAL",
name: "<<Unknown environment>>",
order: 0,
@@ -202,13 +195,10 @@ const makeUnknown = (type: ResourceType) => {
const UNKNOWN_PROJECT: Project = {
id: UNKNOWN_ID,
+ resourceId: "",
rowStatus: "NORMAL",
name: "<<Unknown project>>",
key: "UNK",
- creator: UNKNOWN_PRINCIPAL,
- updater: UNKNOWN_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
memberList: [],
workflowType: "UI",
visibility: "PUBLIC",
@@ -247,18 +237,16 @@ const makeUnknown = (type: ResourceType) => {
const UNKNOWN_INSTANCE: Instance = {
id: UNKNOWN_ID,
+ resourceId: "",
rowStatus: "NORMAL",
environment: UNKNOWN_ENVIRONMENT,
dataSourceList: [],
- creator: UNKNOWN_PRINCIPAL,
- updater: UNKNOWN_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
name: "<<Unknown instance>>",
engine: "MYSQL",
engineVersion: "",
- host: "",
- database: "",
+ externalLink: "",
+ srv: false,
+ authenticationDatabase: "",
};
const UNKNOWN_DATABASE: Database = {
@@ -291,6 +279,17 @@ const makeUnknown = (type: ResourceType) => {
updatedTs: 0,
name: "<<Unknown data source>>",
type: "RO",
+ username: "",
+ password: "",
+ sslCa: "",
+ sslCert: "",
+ sslKey: "",
+ host: "",
+ port: "",
+ database: "",
+ options: { srv: false, authenticationDatabase: "" },
+ // UI-only fields
+ updateSsl: false,
};
const UNKNOWN_BACKUP_SETTING: BackupSetting = {
@@ -415,9 +414,6 @@ const makeUnknown = (type: ResourceType) => {
const UNKNOWN_BOOKMARK: Bookmark = {
id: UNKNOWN_ID,
creator: UNKNOWN_PRINCIPAL,
- updater: UNKNOWN_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
name: "",
link: "",
};
@@ -452,6 +448,8 @@ const makeUnknown = (type: ResourceType) => {
filePathTemplate: "",
schemaPathTemplate: "",
sheetPathTemplate: "",
+ enableSQLReviewCI: false,
+ sqlReviewCIPullRequestURL: "",
externalId: UNKNOWN_ID.toString(),
};
@@ -506,6 +504,7 @@ const makeUnknown = (type: ResourceType) => {
starred: false,
pinned: false,
payload: {},
+ size: 0,
};
const UNKNOWN_SQL_REVIEW_POLICY: SQLReviewPolicy = {
@@ -590,10 +589,6 @@ const makeEmpty = (type: ResourceType) => {
const EMPTY_MEMBER: Member = {
id: EMPTY_ID,
rowStatus: "NORMAL",
- creator: EMPTY_PRINCIPAL,
- updater: EMPTY_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
status: "ACTIVE",
role: "DEVELOPER",
principal: EMPTY_PRINCIPAL,
@@ -601,10 +596,7 @@ const makeEmpty = (type: ResourceType) => {
const EMPTY_ENVIRONMENT: Environment = {
id: EMPTY_ID,
- creator: EMPTY_PRINCIPAL,
- updater: EMPTY_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
+ resourceId: "",
rowStatus: "NORMAL",
name: "",
order: 0,
@@ -613,13 +605,10 @@ const makeEmpty = (type: ResourceType) => {
const EMPTY_PROJECT: Project = {
id: EMPTY_ID,
+ resourceId: "",
rowStatus: "NORMAL",
name: "",
key: "",
- creator: EMPTY_PRINCIPAL,
- updater: EMPTY_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
memberList: [],
workflowType: "UI",
visibility: "PUBLIC",
@@ -658,18 +647,16 @@ const makeEmpty = (type: ResourceType) => {
const EMPTY_INSTANCE: Instance = {
id: EMPTY_ID,
+ resourceId: "",
rowStatus: "NORMAL",
environment: EMPTY_ENVIRONMENT,
dataSourceList: [],
- creator: EMPTY_PRINCIPAL,
- updater: EMPTY_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
name: "",
engine: "MYSQL",
engineVersion: "",
- host: "",
- database: "",
+ externalLink: "",
+ srv: false,
+ authenticationDatabase: "",
};
const EMPTY_DATABASE: Database = {
@@ -702,6 +689,17 @@ const makeEmpty = (type: ResourceType) => {
updatedTs: 0,
name: "",
type: "RO",
+ username: "",
+ password: "",
+ sslCa: "",
+ sslCert: "",
+ sslKey: "",
+ host: "",
+ port: "",
+ database: "",
+ options: { srv: false, authenticationDatabase: "" },
+ // UI-only fields
+ updateSsl: false,
};
const EMPTY_BACKUP_SETTING: BackupSetting = {
@@ -826,9 +824,6 @@ const makeEmpty = (type: ResourceType) => {
const EMPTY_BOOKMARK: Bookmark = {
id: EMPTY_ID,
creator: EMPTY_PRINCIPAL,
- updater: EMPTY_PRINCIPAL,
- createdTs: 0,
- updatedTs: 0,
name: "",
link: "",
};
@@ -863,6 +858,8 @@ const makeEmpty = (type: ResourceType) => {
filePathTemplate: "",
schemaPathTemplate: "",
sheetPathTemplate: "",
+ enableSQLReviewCI: false,
+ sqlReviewCIPullRequestURL: "",
externalId: EMPTY_ID.toString(),
};
@@ -916,6 +913,8 @@ const makeEmpty = (type: ResourceType) => {
type: "SQL",
starred: false,
pinned: false,
+ payload: {},
+ size: 0,
};
const EMPTY_SQL_REVIEW_POLICY: SQLReviewPolicy = {
diff --git a/frontend/src/types/environment.ts b/frontend/src/types/environment.ts
index 51b9cb2a8c..67b9e19e33 100644
--- a/frontend/src/types/environment.ts
+++ b/frontend/src/types/environment.ts
@@ -1,16 +1,12 @@
import { RowStatus } from "./common";
import { EnvironmentId } from "./id";
import { EnvironmentTier } from "./policy";
-import { Principal } from "./principal";
export type Environment = {
id: EnvironmentId;
+ resourceId: string;
// Standard fields
- creator: Principal;
- createdTs: number;
- updater: Principal;
- updatedTs: number;
rowStatus: RowStatus;
// Domain specific fields
diff --git a/frontend/src/types/instance.ts b/frontend/src/types/instance.ts
index 67a6247b5d..05b3f6a7eb 100644
--- a/frontend/src/types/instance.ts
+++ b/frontend/src/types/instance.ts
@@ -2,7 +2,6 @@ import { DataSource } from ".";
import { RowStatus } from "./common";
import { Environment } from "./environment";
import { EnvironmentId, InstanceId, MigrationHistoryId } from "./id";
-import { Principal } from "./principal";
import { VCSPushEvent } from "./vcs";
export type EngineType =
@@ -72,19 +71,14 @@ export function defaultCollation(type: EngineType): string {
export type Instance = {
id: InstanceId;
+ resourceId: string;
+ rowStatus: RowStatus;
// Related fields
environment: Environment;
// An instance must have a admin data source, maybe a read-only data source.
dataSourceList: DataSource[];
- // Standard fields
- creator: Principal;
- createdTs: number;
- updater: Principal;
- updatedTs: number;
- rowStatus: RowStatus;
-
// Domain specific fields
name: string;
engine: EngineType;
diff --git a/frontend/src/types/member.ts b/frontend/src/types/member.ts
index 45fbc55dde..7fa275a3d0 100644
--- a/frontend/src/types/member.ts
+++ b/frontend/src/types/member.ts
@@ -8,13 +8,7 @@ export type RoleType = "OWNER" | "DBA" | "DEVELOPER";
export type Member = {
id: MemberId;
-
- // Standard fields
rowStatus: RowStatus;
- creator: Principal;
- createdTs: number;
- updater: Principal;
- updatedTs: number;
// Domain specific fields
status: MemberStatus;
diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts
index 0877d64cd2..84c027aea6 100644
--- a/frontend/src/types/project.ts
+++ b/frontend/src/types/project.ts
@@ -39,12 +39,7 @@ export const EmptyProjectRoleProviderPayload: ProjectRoleProviderPayload = {
// Project
export type Project = {
id: ProjectId;
-
- // Standard fields
- creator: Principal;
- updater: Principal;
- createdTs: number;
- updatedTs: number;
+ resourceId: string;
rowStatus: RowStatus;
// Domain specific fields
diff --git a/server/member.go b/server/member.go
index 0ca7555654..59fee8539d 100644
--- a/server/member.go
+++ b/server/member.go
@@ -57,11 +57,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {
if err != nil {
return err
}
- bot, err := s.store.GetPrincipalByID(ctx, api.SystemBotID)
- if err != nil {
- return err
- }
- member := convertMember(user, composedPrincipal, bot)
+ member := convertMember(user, composedPrincipal)
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := jsonapi.MarshalPayload(c.Response().Writer, member); err != nil {
@@ -78,10 +74,6 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {
}
var members []*api.Member
- bot, err := s.store.GetPrincipalByID(ctx, api.SystemBotID)
- if err != nil {
- return err
- }
for _, user := range users {
if user.ID == api.SystemBotID {
continue
@@ -90,7 +82,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {
if err != nil {
return err
}
- member := convertMember(user, composedPrincipal, bot)
+ member := convertMember(user, composedPrincipal)
members = append(members, member)
}
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
@@ -211,11 +203,7 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {
if err != nil {
return err
}
- bot, err := s.store.GetPrincipalByID(ctx, api.SystemBotID)
- if err != nil {
- return err
- }
- member := convertMember(user, composedPrincipal, bot)
+ member := convertMember(user, composedPrincipal)
c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)
if err := jsonapi.MarshalPayload(c.Response().Writer, member); err != nil {
@@ -225,14 +213,10 @@ func (s *Server) registerMemberRoutes(g *echo.Group) {
})
}
-func convertMember(user *store.UserMessage, composedPrincipal, bot *api.Principal) *api.Member {
+func convertMember(user *store.UserMessage, composedPrincipal *api.Principal) *api.Member {
member := &api.Member{
ID: user.ID,
RowStatus: api.Normal,
- CreatorID: api.SystemBotID,
- Creator: bot,
- UpdaterID: api.SystemBotID,
- Updater: bot,
Status: api.Active,
Role: user.Role,
PrincipalID: user.ID,
diff --git a/store/backup.go b/store/backup.go
index 66c47f1466..64f57fe1d6 100644
--- a/store/backup.go
+++ b/store/backup.go
@@ -49,9 +49,7 @@ func (raw *backupRaw) toBackup() *api.Backup {
// Standard fields
RowStatus: raw.RowStatus,
- CreatorID: raw.CreatorID,
CreatedTs: raw.CreatedTs,
- UpdaterID: raw.UpdaterID,
UpdatedTs: raw.UpdatedTs,
// Related fields
@@ -123,11 +121,7 @@ func (s *Store) CreateBackup(ctx context.Context, create *api.BackupCreate) (*ap
if err != nil {
return nil, errors.Wrapf(err, "failed to create Backup with BackupCreate[%+v]", create)
}
- backup, err := s.composeBackup(ctx, backupRaw)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Backup with backupRaw[%+v]", backupRaw)
- }
- return backup, nil
+ return composeBackup(backupRaw), nil
}
// GetBackupByID gets an instance of Backup by ID.
@@ -139,11 +133,7 @@ func (s *Store) GetBackupByID(ctx context.Context, id int) (*api.Backup, error)
if backupRaw == nil {
return nil, nil
}
- backupSetting, err := s.composeBackup(ctx, backupRaw)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Backup with backupRaw[%+v]", backupRaw)
- }
- return backupSetting, nil
+ return composeBackup(backupRaw), nil
}
// FindBackup finds a list of Backup instances.
@@ -154,11 +144,7 @@ func (s *Store) FindBackup(ctx context.Context, find *api.BackupFind) ([]*api.Ba
}
var backupList []*api.Backup
for _, raw := range backupRawList {
- backup, err := s.composeBackup(ctx, raw)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Backup with backupRaw[%+v]", raw)
- }
- backupList = append(backupList, backup)
+ backupList = append(backupList, composeBackup(raw))
}
return backupList, nil
}
@@ -169,11 +155,7 @@ func (s *Store) PatchBackup(ctx context.Context, patch *api.BackupPatch) (*api.B
if err != nil {
return nil, errors.Wrapf(err, "failed to patch Backup with BackupPatch[%+v]", patch)
}
- backup, err := s.composeBackup(ctx, backupRaw)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Backup with backupRaw[%+v]", backupRaw)
- }
- return backup, nil
+ return composeBackup(backupRaw), nil
}
// FindBackupSetting finds a list of BackupSetting of databases in the instance.
@@ -276,22 +258,8 @@ func (s *Store) FindBackupSettingsMatch(ctx context.Context, match *api.BackupSe
//
// composeBackup composes an instance of Backup by backupRaw.
-func (s *Store) composeBackup(ctx context.Context, raw *backupRaw) (*api.Backup, error) {
- backup := raw.toBackup()
-
- creator, err := s.GetPrincipalByID(ctx, backup.CreatorID)
- if err != nil {
- return nil, err
- }
- backup.Creator = creator
-
- updater, err := s.GetPrincipalByID(ctx, backup.UpdaterID)
- if err != nil {
- return nil, err
- }
- backup.Updater = updater
-
- return backup, nil
+func composeBackup(raw *backupRaw) *api.Backup {
+ return raw.toBackup()
}
func (s *Store) composeBackupSetting(ctx context.Context, raw *backupSettingRaw) (*api.BackupSetting, error) {
diff --git a/store/bookmark.go b/store/bookmark.go
index e421055663..44875a2939 100644
--- a/store/bookmark.go
+++ b/store/bookmark.go
@@ -36,9 +36,6 @@ func (raw *bookmarkRaw) toBookmark() *api.Bookmark {
// Standard fields
CreatorID: raw.CreatorID,
- CreatedTs: raw.CreatedTs,
- UpdaterID: raw.UpdaterID,
- UpdatedTs: raw.UpdatedTs,
// Domain specific fields
Name: raw.Name,
@@ -106,12 +103,6 @@ func (s *Store) composeBookmark(ctx context.Context, raw *bookmarkRaw) (*api.Boo
}
bookmark.Creator = creator
- updater, err := s.GetPrincipalByID(ctx, bookmark.UpdaterID)
- if err != nil {
- return nil, err
- }
- bookmark.Updater = updater
-
return bookmark, nil
}
diff --git a/store/environment.go b/store/environment.go
index bde4cdf306..44bf313d22 100644
--- a/store/environment.go
+++ b/store/environment.go
@@ -53,11 +53,7 @@ func (s *Store) CreateEnvironment(ctx context.Context, create *EnvironmentCreate
return nil, errors.Wrapf(err, "failed to create Environment with EnvironmentCreate[%+v]", create)
}
- composedEnvironment, err := s.composeEnvironment(ctx, environment)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Environment with environmentRaw[%+v]", environment)
- }
- return composedEnvironment, nil
+ return composeEnvironment(environment), nil
}
// FindEnvironment finds a list of Environment instances.
@@ -72,10 +68,7 @@ func (s *Store) FindEnvironment(ctx context.Context, find *api.EnvironmentFind)
})
var composedEnvironmentList []*api.Environment
for _, environment := range environments {
- composedEnvironment, err := s.composeEnvironment(ctx, environment)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Environment role with environmentRaw[%+v]", environment)
- }
+ composedEnvironment := composeEnvironment(environment)
if find.RowStatus != nil && composedEnvironment.RowStatus != *find.RowStatus {
continue
}
@@ -108,10 +101,7 @@ func (s *Store) PatchEnvironment(ctx context.Context, patch *EnvironmentPatch) (
if err != nil {
return nil, errors.Wrapf(err, "failed to patch Environment with EnvironmentPatch[%+v]", patch)
}
- composedEnvironment, err := s.composeEnvironment(ctx, environment)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose Environment with environmentRaw[%+v]", environment)
- }
+ composedEnvironment := composeEnvironment(environment)
return composedEnvironment, nil
}
@@ -125,19 +115,11 @@ func (s *Store) GetEnvironmentByID(ctx context.Context, id int) (*api.Environmen
return nil, common.Errorf(common.NotFound, "environment %d not found", id)
}
- env, err := s.composeEnvironment(ctx, environment)
- if err != nil {
- return nil, errors.Wrapf(err, "failed to compose environment with environmentRaw[%+v]", environment)
- }
-
+ env := composeEnvironment(environment)
return env, nil
}
-//
-// private functions
-//
-
-func (s *Store) composeEnvironment(ctx context.Context, raw *EnvironmentMessage) (*api.Environment, error) {
+func composeEnvironment(raw *EnvironmentMessage) *api.Environment {
rowStatus := api.Normal
if raw.Deleted {
rowStatus = api.Archived
@@ -146,30 +128,21 @@ func (s *Store) composeEnvironment(ctx context.Context, raw *EnvironmentMessage)
if raw.Protected {
tier = api.EnvironmentTierValueProtected
}
- ret := &api.Environment{
+ return &api.Environment{
ID: raw.UID,
ResourceID: raw.ResourceID,
-
- RowStatus: rowStatus,
- CreatorID: api.SystemBotID,
- CreatedTs: 0,
- UpdaterID: api.SystemBotID,
- UpdatedTs: 0,
+ RowStatus: rowStatus,
Name: raw.Title,
Order: int(raw.Order),
Tier: tier,
}
- bot, err := s.GetPrincipalByID(ctx, api.SystemBotID)
- if err != nil {
- return nil, err
- }
- ret.Creator = bot
- ret.Updater = bot
-
- return ret, nil
}
+//
+// V1 store.
+//
+
// EnvironmentMessage is the mssage for environment.
type EnvironmentMessage struct {
ResourceID string
diff --git a/store/instance.go b/store/instance.go
index 390606c3c9..8726cebf6c 100644
--- a/store/instance.go
+++ b/store/instance.go
@@ -89,13 +89,7 @@ func (raw *instanceRaw) toInstance() *api.Instance {
return &api.Instance{
ID: raw.ID,
ResourceID: raw.ResourceID,
-
- // Standard fields
- RowStatus: raw.RowStatus,
- CreatorID: raw.CreatorID,
- CreatedTs: raw.CreatedTs,
- UpdaterID: raw.UpdaterID,
- UpdatedTs: raw.UpdatedTs,
+ RowStatus: raw.RowStatus,
// Related fields
EnvironmentID: raw.EnvironmentID,
@@ -322,18 +316,6 @@ func (s *Store) GetInstanceSslSuiteByID(ctx context.Context, instanceID int) (db
func (s *Store) composeInstance(ctx context.Context, raw *instanceRaw) (*api.Instance, error) {
instance := raw.toInstance()
- creator, err := s.GetPrincipalByID(ctx, instance.CreatorID)
- if err != nil {
- return nil, err
- }
- instance.Creator = creator
-
- updater, err := s.GetPrincipalByID(ctx, instance.UpdaterID)
- if err != nil {
- return nil, err
- }
- instance.Updater = updater
-
env, err := s.GetEnvironmentByID(ctx, instance.EnvironmentID)
if err != nil {
return nil, err
diff --git a/store/project.go b/store/project.go
index b38dab8cfc..16fba49c77 100644
--- a/store/project.go
+++ b/store/project.go
@@ -153,8 +153,6 @@ func (s *Store) composeProject(ctx context.Context, project *ProjectMessage) (*a
ID: project.UID,
ResourceID: project.ResourceID,
RowStatus: api.Normal,
- CreatorID: api.SystemBotID,
- UpdaterID: api.SystemBotID,
Name: project.Title,
Key: project.Key,
WorkflowType: project.Workflow,
@@ -169,13 +167,6 @@ func (s *Store) composeProject(ctx context.Context, project *ProjectMessage) (*a
composedProject.RowStatus = api.Archived
}
- bot, err := s.GetPrincipalByID(ctx, api.SystemBotID)
- if err != nil {
- return nil, err
- }
- composedProject.Creator = bot
- composedProject.Updater = bot
-
// TODO(d): migrate FindProjectMember to v2.
projectMemberList, err := s.FindProjectMember(ctx, &api.ProjectMemberFind{ProjectID: &project.UID})
if err != nil {
diff --git a/tests/backup_restore_test.go b/tests/backup_restore_test.go
index b760e69da1..0942c11992 100644
--- a/tests/backup_restore_test.go
+++ b/tests/backup_restore_test.go
@@ -337,7 +337,7 @@ func TestPITRToNewDatabaseInAnotherInstance(t *testing.T) {
ProjectID: project.ID,
Name: fmt.Sprintf("Restore database %s to the time %d", database.Name, targetTs),
Type: api.IssueDatabaseRestorePITR,
- AssigneeID: project.Creator.ID,
+ AssigneeID: api.SystemBotID,
CreateContext: string(pitrIssueCtx),
})
a.NoError(err)
@@ -391,7 +391,7 @@ func createPITRIssue(ctl *controller, project *api.Project, pitrContext api.PITR
ProjectID: project.ID,
Name: fmt.Sprintf("Restore database %d", pitrContext.DatabaseID),
Type: api.IssueDatabaseRestorePITR,
- AssigneeID: project.Creator.ID,
+ AssigneeID: api.SystemBotID,
CreateContext: string(pitrIssueCtx),
})
}
diff --git a/tests/database.go b/tests/database.go
index 06f3808897..2f404deb44 100644
--- a/tests/database.go
+++ b/tests/database.go
@@ -40,12 +40,11 @@ func (ctl *controller) createDatabase(project *api.Project, instance *api.Instan
return errors.Wrap(err, "failed to construct database creation issue CreateContext payload")
}
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("create database %q", databaseName),
- Type: api.IssueDatabaseCreate,
- Description: fmt.Sprintf("This creates a database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("create database %q", databaseName),
+ Type: api.IssueDatabaseCreate,
+ Description: fmt.Sprintf("This creates a database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
if err != nil {
@@ -90,12 +89,11 @@ func (ctl *controller) cloneDatabaseFromBackup(project *api.Project, instance *a
return errors.Wrap(err, "failed to construct database creation issue CreateContext payload")
}
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("create database %q from backup %q", databaseName, backup.Name),
- Type: api.IssueDatabaseCreate,
- Description: fmt.Sprintf("This creates a database %q from backup %q.", databaseName, backup.Name),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("create database %q from backup %q", databaseName, backup.Name),
+ Type: api.IssueDatabaseCreate,
+ Description: fmt.Sprintf("This creates a database %q from backup %q.", databaseName, backup.Name),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
if err != nil {
diff --git a/tests/external_approval_test.go b/tests/external_approval_test.go
index a914a47308..a702823e3b 100644
--- a/tests/external_approval_test.go
+++ b/tests/external_approval_test.go
@@ -58,7 +58,6 @@ func TestExternalApprovalFeishu_AllUserCanBeFound(t *testing.T) {
a.NoError(err)
_, err = ctl.createMember(api.MemberCreate{
- Status: api.Active,
Role: api.DBA,
PrincipalID: dba.ID,
})
@@ -214,7 +213,6 @@ func TestExternalApprovalFeishu_AssigneeCanBeFound(t *testing.T) {
a.NoError(err)
_, err = ctl.createMember(api.MemberCreate{
- Status: api.Active,
Role: api.DBA,
PrincipalID: dba.ID,
})
diff --git a/tests/ghost_test.go b/tests/ghost_test.go
index 0423fa571e..b36c6d0328 100644
--- a/tests/ghost_test.go
+++ b/tests/ghost_test.go
@@ -154,12 +154,11 @@ func TestGhostSchemaUpdate(t *testing.T) {
a.NoError(err)
// Create an issue updating database schema.
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -186,7 +185,7 @@ func TestGhostSchemaUpdate(t *testing.T) {
Name: fmt.Sprintf("update schema for database %q", databaseName),
Type: api.IssueDatabaseSchemaUpdateGhost,
Description: fmt.Sprintf("This updates the schema of database %q using gh-ost", databaseName),
- AssigneeID: project.Creator.ID,
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -342,12 +341,11 @@ func TestGhostTenant(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -379,12 +377,11 @@ func TestGhostTenant(t *testing.T) {
})
a.NoError(err)
issue, err = ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdateGhost,
- Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdateGhost,
+ Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/project_test.go b/tests/project_test.go
index e636dbe7d1..71217be726 100644
--- a/tests/project_test.go
+++ b/tests/project_test.go
@@ -62,7 +62,6 @@ func TestArchiveProject(t *testing.T) {
err = ctl.patchProject(api.ProjectPatch{
ID: project.ID,
RowStatus: &status,
- UpdaterID: project.Creator.ID,
})
a.Error(err)
})
@@ -88,12 +87,11 @@ func TestArchiveProject(t *testing.T) {
a.NoError(err)
_, err = ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("create database %q", databaseName),
- Type: api.IssueDatabaseCreate,
- Description: fmt.Sprintf("This creates a database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("create database %q", databaseName),
+ Type: api.IssueDatabaseCreate,
+ Description: fmt.Sprintf("This creates a database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(c),
})
a.NoError(err)
@@ -102,7 +100,6 @@ func TestArchiveProject(t *testing.T) {
err = ctl.patchProject(api.ProjectPatch{
ID: project.ID,
RowStatus: &status,
- UpdaterID: project.Creator.ID,
})
a.Error(err)
})
diff --git a/tests/rollback_test.go b/tests/rollback_test.go
index caf1ce5f6f..e51820f78f 100644
--- a/tests/rollback_test.go
+++ b/tests/rollback_test.go
@@ -179,7 +179,7 @@ func TestCreateRollbackIssueMySQL(t *testing.T) {
ProjectID: project.ID,
Name: "update data",
Type: api.IssueDatabaseDataUpdate,
- AssigneeID: project.Creator.ID,
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -222,7 +222,7 @@ func TestCreateRollbackIssueMySQL(t *testing.T) {
ProjectID: project.ID,
Name: "rollback",
Type: api.IssueDatabaseRollback,
- AssigneeID: project.Creator.ID,
+ AssigneeID: api.SystemBotID,
CreateContext: string(rollbackCreateContext),
})
if err == nil {
diff --git a/tests/schema_update_test.go b/tests/schema_update_test.go
index e9c49173dd..3595fa96d1 100644
--- a/tests/schema_update_test.go
+++ b/tests/schema_update_test.go
@@ -111,12 +111,11 @@ func TestSchemaAndDataUpdate(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -141,12 +140,11 @@ func TestSchemaAndDataUpdate(t *testing.T) {
})
a.NoError(err)
issue, err = ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update data for database %q", databaseName),
- Type: api.IssueDatabaseDataUpdate,
- Description: fmt.Sprintf("This updates the data of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update data for database %q", databaseName),
+ Type: api.IssueDatabaseDataUpdate,
+ Description: fmt.Sprintf("This updates the data of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -1966,12 +1964,11 @@ CREATE TABLE public.book (
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", test.databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("This updates the schema of database %q.", test.databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", test.databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("This updates the schema of database %q.", test.databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -2071,12 +2068,11 @@ func TestMarkTaskAsDone(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/sensitive_data_test.go b/tests/sensitive_data_test.go
index cbcd2488ef..6df20a4ea0 100644
--- a/tests/sensitive_data_test.go
+++ b/tests/sensitive_data_test.go
@@ -130,12 +130,11 @@ func TestSensitiveData(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("Create table for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("Create table of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("Create table for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("Create table of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -181,12 +180,11 @@ func TestSensitiveData(t *testing.T) {
})
a.NoError(err)
issue, err = ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update data for database %q", databaseName),
- Type: api.IssueDatabaseDataUpdate,
- Description: fmt.Sprintf("This updates the data of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update data for database %q", databaseName),
+ Type: api.IssueDatabaseDataUpdate,
+ Description: fmt.Sprintf("This updates the data of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/sql_editor_test.go b/tests/sql_editor_test.go
index cf47ab74aa..f77cb650af 100644
--- a/tests/sql_editor_test.go
+++ b/tests/sql_editor_test.go
@@ -152,12 +152,11 @@ func TestAdminQueryAffectedRows(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("Prepare statements of database %q", tt.databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("Prepare statements of database %q.", tt.databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("Prepare statements of database %q", tt.databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("Prepare statements of database %q.", tt.databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/sql_review_test.go b/tests/sql_review_test.go
index 2f02f0b401..2b4e8ebd7f 100644
--- a/tests/sql_review_test.go
+++ b/tests/sql_review_test.go
@@ -344,7 +344,7 @@ func TestSQLReviewForPostgreSQL(t *testing.T) {
a.Equal(instance.ID, database.Instance.ID)
for _, t := range tests {
- result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, t.statement, t.run)
+ result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, t.statement, t.run)
a.Equal(t.result, result)
}
@@ -359,7 +359,7 @@ func TestSQLReviewForPostgreSQL(t *testing.T) {
})
a.NoError(err)
- result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, statements[0], false)
+ result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, statements[0], false)
a.Equal(noSQLReviewPolicy, result)
// delete the SQL review policy
@@ -370,7 +370,7 @@ func TestSQLReviewForPostgreSQL(t *testing.T) {
})
a.NoError(err)
- result = createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, statements[0], false)
+ result = createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, statements[0], false)
a.Equal(noSQLReviewPolicy, result)
}
@@ -1078,7 +1078,7 @@ func TestSQLReviewForMySQL(t *testing.T) {
a.Equal(instance.ID, database.Instance.ID)
for _, t := range tests {
- result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, t.statement, t.run)
+ result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, t.statement, t.run)
a.Equal(t.result, result, t.statement)
}
@@ -1098,14 +1098,14 @@ func TestSQLReviewForMySQL(t *testing.T) {
`INSERT INTO test(id, name) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd');`,
}
for _, stmt := range initialStmts {
- createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, stmt, true /* wait */)
+ createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, stmt, true /* wait */)
}
countSQL := "SELECT count(*) FROM test WHERE 1=1;"
dmlSQL := "INSERT INTO test SELECT * FROM " + valueTable
origin, err := ctl.query(instance, databaseName, countSQL)
a.NoError(err)
a.Equal("[[\"count(*)\"],[\"BIGINT\"],[[\"4\"]]]", origin)
- createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, dmlSQL, false /* wait */)
+ createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, dmlSQL, false /* wait */)
finial, err := ctl.query(instance, databaseName, countSQL)
a.NoError(err)
a.Equal(origin, finial)
@@ -1121,7 +1121,7 @@ func TestSQLReviewForMySQL(t *testing.T) {
})
a.NoError(err)
- result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, statements[0], false)
+ result := createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, statements[0], false)
a.Equal(noSQLReviewPolicy, result)
// delete the SQL review policy
@@ -1132,11 +1132,11 @@ func TestSQLReviewForMySQL(t *testing.T) {
})
a.NoError(err)
- result = createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, project.Creator.ID, statements[0], false)
+ result = createIssueAndReturnSQLReviewResult(a, ctl, database.ID, project.ID, statements[0], false)
a.Equal(noSQLReviewPolicy, result)
}
-func createIssueAndReturnSQLReviewResult(a *require.Assertions, ctl *controller, databaseID int, projectID int, assigneeID int, statement string, wait bool) []api.TaskCheckResult {
+func createIssueAndReturnSQLReviewResult(a *require.Assertions, ctl *controller, databaseID int, projectID int, statement string, wait bool) []api.TaskCheckResult {
createContext, err := json.Marshal(&api.MigrationContext{
DetailList: []*api.MigrationDetail{
{
@@ -1153,7 +1153,7 @@ func createIssueAndReturnSQLReviewResult(a *require.Assertions, ctl *controller,
Name: "update schema for database",
Type: api.IssueDatabaseSchemaUpdate,
Description: "This updates the schema of database",
- AssigneeID: assigneeID,
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/sync_schema_test.go b/tests/sync_schema_test.go
index 2f291e4efc..9437bf8fc5 100644
--- a/tests/sync_schema_test.go
+++ b/tests/sync_schema_test.go
@@ -124,12 +124,11 @@ DROP SCHEMA "schema_a";
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("Create sequence for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("Create sequence of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("Create sequence for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("Create sequence of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/syncer_test.go b/tests/syncer_test.go
index ee313f27b1..b3564ec1e1 100644
--- a/tests/syncer_test.go
+++ b/tests/syncer_test.go
@@ -211,12 +211,11 @@ func TestSyncerForPostgreSQL(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("Create sequence for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("Create sequence of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("Create sequence for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("Create sequence of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -491,12 +490,11 @@ func TestSyncerForMySQL(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("Create sequence for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("Create sequence of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("Create sequence for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("Create sequence of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
diff --git a/tests/tenant_test.go b/tests/tenant_test.go
index 09c0257dfd..6adf17ce93 100644
--- a/tests/tenant_test.go
+++ b/tests/tenant_test.go
@@ -153,12 +153,11 @@ func TestTenant(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: fmt.Sprintf("update schema for database %q", databaseName),
- Type: api.IssueDatabaseSchemaUpdate,
- Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: fmt.Sprintf("update schema for database %q", databaseName),
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: fmt.Sprintf("This updates the schema of database %q.", databaseName),
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)
@@ -617,12 +616,11 @@ func TestTenantDatabaseNameTemplate(t *testing.T) {
})
a.NoError(err)
issue, err := ctl.createIssue(api.IssueCreate{
- ProjectID: project.ID,
- Name: "update schema for tenants",
- Type: api.IssueDatabaseSchemaUpdate,
- Description: "This updates the schema of tenant databases.",
- // Assign to self.
- AssigneeID: project.Creator.ID,
+ ProjectID: project.ID,
+ Name: "update schema for tenants",
+ Type: api.IssueDatabaseSchemaUpdate,
+ Description: "This updates the schema of tenant databases.",
+ AssigneeID: api.SystemBotID,
CreateContext: string(createContext),
})
a.NoError(err)