Skip to content

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

chore: revert changes to disable changing project key (#2653)

Yilong Li0c05db795821
diff --git a/api/project.go b/api/project.go
index d228ddedb2..fbf216827a 100644
--- a/api/project.go
+++ b/api/project.go
@@ -131,6 +131,7 @@ type ProjectPatch struct {
// Domain specific fields
Name *string `jsonapi:"attr,name"`
+ Key *string `jsonapi:"attr,key"`
WorkflowType *string `jsonapi:"attr,workflowType"` // NOTE: We can't use *ProjectWorkflowType because "google/jsonapi" doesn't support.
RoleProvider *string `jsonapi:"attr,roleProvider"`
SchemaChangeType *string `jsonapi:"attr,schemaChangeType"` // NOTE: We can't use *ProjectSchemaChangeType because "google/jsonapi" doesn't support.
diff --git a/frontend/src/components/ProjectGeneralSettingPanel.vue b/frontend/src/components/ProjectGeneralSettingPanel.vue
index 26ba19d9a8..f51a287a3b 100644
--- a/frontend/src/components/ProjectGeneralSettingPanel.vue
+++ b/frontend/src/components/ProjectGeneralSettingPanel.vue
@@ -23,13 +23,13 @@
<dl class="">
<dt class="text-sm font-medium text-control-light">
- {{ $t("common.key") }}
+ {{ $t("common.key") }} <span class="text-red-600">*</span>
</dt>
<dd class="mt-1 text-sm text-main">
<input
id="projectKey"
- :value="project.key"
- disabled
+ :value="state.key"
+ :disabled="!allowEdit"
required
autocomplete="off"
type="text"
@@ -94,6 +94,7 @@ import { pushNotification, useProjectStore } from "@/store";
interface LocalState {
name: string;
+ key: string;
schemaChangeType: SchemaChangeType;
}
@@ -115,6 +116,7 @@ export default defineComponent({
const state = reactive<LocalState>({
name: props.project.name,
+ key: props.project.key,
schemaChangeType: props.project.schemaChangeType,
});
@@ -133,6 +135,9 @@ export default defineComponent({
if (state.name !== props.project.name) {
projectPatch.name = state.name;
}
+ if (state.key !== props.project.key) {
+ projectPatch.key = state.key;
+ }
if (state.schemaChangeType !== props.project.schemaChangeType) {
projectPatch.schemaChangeType = state.schemaChangeType;
}
diff --git a/frontend/src/types/project.ts b/frontend/src/types/project.ts
index 765864378d..d7556b9936 100644
--- a/frontend/src/types/project.ts
+++ b/frontend/src/types/project.ts
@@ -71,6 +71,7 @@ export type ProjectPatch = {
// Domain specific fields
name?: string;
+ key?: string;
roleProvider?: ProjectRoleProvider;
schemaChangeType?: SchemaChangeType;
};
diff --git a/store/project.go b/store/project.go
index 4d6aa4c83a..202b8aad20 100644
--- a/store/project.go
+++ b/store/project.go
@@ -549,6 +549,9 @@ func patchProjectImpl(ctx context.Context, tx *Tx, patch *api.ProjectPatch, mode
if v := patch.Name; v != nil {
set, args = append(set, fmt.Sprintf("name = $%d", len(args)+1)), append(args, *v)
}
+ if v := patch.Key; v != nil {
+ set, args = append(set, fmt.Sprintf("key = $%d", len(args)+1)), append(args, strings.ToUpper(*v))
+ }
if v := patch.WorkflowType; v != nil {
set, args = append(set, fmt.Sprintf("workflow_type = $%d", len(args)+1)), append(args, *v)
}