Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Add engine column to instance to denote db engine type.
天舟4a72771998c9
diff --git a/backend/api/instance.go b/backend/api/instance.goindex 0c34075480..904ffb8857 100644--- a/backend/api/instance.go+++ b/backend/api/instance.go@@ -3,6 +3,8 @@ package apiimport ("context""encoding/json"++ "github.com/bytebase/bytebase/db")type Instance struct {@@ -24,10 +26,11 @@ type Instance struct {DataSourceList []*DataSource `jsonapi:"relation,dataSource"`// Domain specific fields- Name string `jsonapi:"attr,name"`- ExternalLink string `jsonapi:"attr,externalLink"`- Host string `jsonapi:"attr,host"`- Port string `jsonapi:"attr,port"`+ Name string `jsonapi:"attr,name"`+ Engine db.Type `jsonapi:"attr,engine"`+ ExternalLink string `jsonapi:"attr,externalLink"`+ Host string `jsonapi:"attr,host"`+ Port string `jsonapi:"attr,port"`// Only returns username/password if supplying query parameter 'include=secret'Username string `jsonapi:"attr,username"`Password string `jsonapi:"attr,password"`@@ -43,12 +46,13 @@ type InstanceCreate struct {EnvironmentId int `jsonapi:"attr,environmentId"`// Domain specific fields- Name string `jsonapi:"attr,name"`- ExternalLink string `jsonapi:"attr,externalLink"`- Host string `jsonapi:"attr,host"`- Port string `jsonapi:"attr,port"`- Username string `jsonapi:"attr,username"`- Password string `jsonapi:"attr,password"`+ Name string `jsonapi:"attr,name"`+ Type db.Type `jsonapi:"attr,type"`+ ExternalLink string `jsonapi:"attr,externalLink"`+ Host string `jsonapi:"attr,host"`+ Port string `jsonapi:"attr,port"`+ Username string `jsonapi:"attr,username"`+ Password string `jsonapi:"attr,password"`}type InstanceFind struct {diff --git a/backend/db/driver.go b/backend/db/driver.goindex f802b0b5e0..63d0793c06 100644--- a/backend/db/driver.go+++ b/backend/db/driver.go@@ -19,7 +19,7 @@ func (e Type) String() string {case Mysql:return "MYSQL"}- return ""+ return "UNKNOWN"}type DBSchema struct {diff --git a/backend/store/instance.go b/backend/store/instance.goindex 2d0e51d829..4a703137cd 100644--- a/backend/store/instance.go+++ b/backend/store/instance.go@@ -112,12 +112,13 @@ func createInstance(ctx context.Context, tx *Tx, create *api.InstanceCreate) (*aworkspace_id,environment_id,name,+ engine,external_link,host,port)VALUES (?, ?, ?, ?, ?, ?, ?, ?)- RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, workspace_id, environment_id, name, external_link, host, port+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, workspace_id, environment_id, name, engine, external_link, host, port`,create.CreatorId,create.CreatorId,@@ -146,6 +147,7 @@ func createInstance(ctx context.Context, tx *Tx, create *api.InstanceCreate) (*a&instance.WorkspaceId,&instance.EnvironmentId,&instance.Name,+ &instance.Engine,&instance.ExternalLink,&instance.Host,&instance.Port,@@ -180,6 +182,7 @@ func findInstanceList(ctx context.Context, tx *Tx, find *api.InstanceFind) (_ []workspace_id,environment_id,name,+ engine,external_link,host,port@@ -206,6 +209,7 @@ func findInstanceList(ctx context.Context, tx *Tx, find *api.InstanceFind) (_ []&instance.WorkspaceId,&instance.EnvironmentId,&instance.Name,+ &instance.Engine,&instance.ExternalLink,&instance.Host,&instance.Port,@@ -249,7 +253,7 @@ func patchInstance(ctx context.Context, tx *Tx, patch *api.InstancePatch) (*api.UPDATE instanceSET `+strings.Join(set, ", ")+`WHERE id = ?- RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, workspace_id, environment_id, name, external_link, host, port+ RETURNING id, row_status, creator_id, created_ts, updater_id, updated_ts, workspace_id, environment_id, name, engine, external_link, host, port`,args...,)@@ -270,6 +274,7 @@ func patchInstance(ctx context.Context, tx *Tx, patch *api.InstancePatch) (*api.&instance.WorkspaceId,&instance.EnvironmentId,&instance.Name,+ &instance.Engine,&instance.ExternalLink,&instance.Host,&instance.Port,diff --git a/backend/store/migration/0001_init_schema.up.sql b/backend/store/migration/0001_init_schema.up.sqlindex f1e95ffd43..9dd9204eaa 100644--- a/backend/store/migration/0001_init_schema.up.sql+++ b/backend/store/migration/0001_init_schema.up.sql@@ -277,6 +277,7 @@ CREATE TABLE instance (workspace_id INTEGER NOT NULL REFERENCES workspace (id),environment_id INTEGER NOT NULL REFERENCES environment (id),name TEXT NOT NULL,+ `engine` TEXT NOT NULL CHECK (`engine` IN ('MYSQL')),external_link TEXT NOT NULL,host TEXT NOT NULL,port TEXT NOT NULLdiff --git a/backend/store/seed/0060_instance.sql b/backend/store/seed/0060_instance.sqlindex bdf9ca0bb2..2d9e6e8819 100644--- a/backend/store/seed/0060_instance.sql+++ b/backend/store/seed/0060_instance.sql@@ -6,6 +6,7 @@ INSERT INTOworkspace_id,environment_id,name,+ `engine`,external_link,host,port@@ -18,6 +19,7 @@ VALUES1,5001,'On-premise MySQL instance',+ 'MYSQL','localhost','127.0.0.1','33060'@@ -31,6 +33,7 @@ INSERT INTOworkspace_id,environment_id,name,+ `engine`,external_link,host,port@@ -43,6 +46,7 @@ VALUES1,5002,'AWS RDS instance',+ 'MYSQL','google.com','127.0.0.1',''@@ -56,6 +60,7 @@ INSERT INTOworkspace_id,environment_id,name,+ `engine`,external_link,host,port@@ -68,6 +73,7 @@ VALUES1,5003,'GCP Cloud SQL instance',+ 'MYSQL','google.com','13.24.32.122','15202'@@ -81,6 +87,7 @@ INSERT INTOworkspace_id,environment_id,name,+ `engine`,external_link,host,port@@ -93,6 +100,7 @@ VALUES1,5004,'Azure SQL instance',+ 'MYSQL','google.com','mydb.com','1234'@@ -106,6 +114,7 @@ INSERT INTOworkspace_id,environment_id,name,+ `engine`,external_link,host,port@@ -118,6 +127,7 @@ VALUES1,5004,'AliCloud RDS instance',+ 'MYSQL','google.com','rds.com','5678'diff --git a/frontend/src/components/InstanceTable.vue b/frontend/src/components/InstanceTable.vueindex 64566f3564..d8816c32aa 100644--- a/frontend/src/components/InstanceTable.vue+++ b/frontend/src/components/InstanceTable.vue@@ -9,7 +9,11 @@><template v-slot:body="{ rowData: instance }"><BBTableCell :leftPadding="4" class="w-8">- <img class="h-10 w-auto" src="../assets/db-mysql.svg" />+ <img+ v-if="instance.engine == 'MYSQL'"+ class="h-10 w-auto"+ src="../assets/db-mysql.svg"+ /></BBTableCell><BBTableCell class="w-32">{{ instanceName(instance) }}diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 34706acc76..eba596c1b6 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -171,6 +171,7 @@ export const unknown = (createdTs: 0,updatedTs: 0,name: "<<Unknown instance>>",+ engine: "MYSQL",host: "",};@@ -410,6 +411,7 @@ export const empty = (createdTs: 0,updatedTs: 0,name: "",+ engine: "MYSQL",host: "",};diff --git a/frontend/src/types/instance.ts b/frontend/src/types/instance.tsindex dab39dabfb..9b8c9fd5ea 100644--- a/frontend/src/types/instance.ts+++ b/frontend/src/types/instance.ts@@ -3,6 +3,8 @@ import { Environment } from "./environment";import { EnvironmentId, InstanceId, PrincipalId } from "./id";import { Principal } from "./principal";+export type EngineType = "MYSQL";+export type Instance = {id: InstanceId;@@ -18,6 +20,7 @@ export type Instance = {// Domain specific fieldsname: string;+ engine: EngineType;externalLink?: string;host: string;port?: string;