Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: add instance metadata and mysql lower_case_table_name config (#7247)
rebelice90ac6d192c81
diff --git a/backend/migrator/migration/dev/LATEST.sql b/backend/migrator/migration/dev/LATEST.sqlindex 00fdfb3e40..6a06396bdb 100644--- a/backend/migrator/migration/dev/LATEST.sql+++ b/backend/migrator/migration/dev/LATEST.sql@@ -333,7 +333,8 @@ CREATE TABLE instance (resource_id TEXT NOT NULL,-- activation should set to be TRUE if users assign license to this instance.activation BOOLEAN NOT NULL DEFAULT false,- options JSONB NOT NULL DEFAULT '{}'+ options JSONB NOT NULL DEFAULT '{}',+ metadata JSONB NOT NULL DEFAULT '{}');CREATE UNIQUE INDEX idx_instance_unique_resource_id ON instance(resource_id);diff --git a/backend/migrator/migration/prod/2.5/0004##add_instance_metadata.sql b/backend/migrator/migration/prod/2.5/0004##add_instance_metadata.sqlnew file mode 100644index 0000000000..29ca3a415b--- /dev/null+++ b/backend/migrator/migration/prod/2.5/0004##add_instance_metadata.sql@@ -0,0 +1 @@+ALTER TABLE instance ADD COLUMN metadata JSONB NOT NULL DEFAULT '{}';\ No newline at end of filediff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sqlindex 34ced34377..50a1ba0d0c 100644--- a/backend/migrator/migration/prod/LATEST.sql+++ b/backend/migrator/migration/prod/LATEST.sql@@ -332,7 +332,8 @@ CREATE TABLE instance (resource_id TEXT NOT NULL,-- activation should set to be TRUE if users assign license to this instance.activation BOOLEAN NOT NULL DEFAULT false,- options JSONB NOT NULL DEFAULT '{}'+ options JSONB NOT NULL DEFAULT '{}',+ metadata JSONB NOT NULL DEFAULT '{}');CREATE UNIQUE INDEX idx_instance_unique_resource_id ON instance(resource_id);diff --git a/backend/migrator/migrator_test.go b/backend/migrator/migrator_test.goindex 281f697942..7924cbd928 100644--- a/backend/migrator/migrator_test.go+++ b/backend/migrator/migrator_test.go@@ -241,5 +241,5 @@ func TestMigrationCompatibility(t *testing.T) {func TestGetCutoffVersion(t *testing.T) {releaseVersion, err := getProdCutoffVersion()require.NoError(t, err)- require.Equal(t, semver.MustParse("2.5.3"), releaseVersion)+ require.Equal(t, semver.MustParse("2.5.4"), releaseVersion)}diff --git a/frontend/src/types/proto/store/instance.ts b/frontend/src/types/proto/store/instance.tsindex 69f93e11dc..db01c350c0 100644--- a/frontend/src/types/proto/store/instance.ts+++ b/frontend/src/types/proto/store/instance.ts@@ -12,6 +12,15 @@ export interface InstanceOptions {schemaTenantMode: boolean;}+/** InstanceMetadata is the metadata for instances. */+export interface InstanceMetadata {+ /**+ * The lower_case_table_name config for MySQL instances.+ * It is used to determine whether the table name and database name are case sensitive.+ */+ mysqlLowerCaseTableName: number;+}+function createBaseInstanceOptions(): InstanceOptions {return { schemaTenantMode: false };}@@ -68,6 +77,65 @@ export const InstanceOptions = {},};+function createBaseInstanceMetadata(): InstanceMetadata {+ return { mysqlLowerCaseTableName: 0 };+}++export const InstanceMetadata = {+ encode(message: InstanceMetadata, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.mysqlLowerCaseTableName !== 0) {+ writer.uint32(8).int32(message.mysqlLowerCaseTableName);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): InstanceMetadata {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseInstanceMetadata();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 8) {+ break;+ }++ message.mysqlLowerCaseTableName = reader.int32();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): InstanceMetadata {+ return {+ mysqlLowerCaseTableName: isSet(object.mysqlLowerCaseTableName) ? Number(object.mysqlLowerCaseTableName) : 0,+ };+ },++ toJSON(message: InstanceMetadata): unknown {+ const obj: any = {};+ message.mysqlLowerCaseTableName !== undefined &&+ (obj.mysqlLowerCaseTableName = Math.round(message.mysqlLowerCaseTableName));+ return obj;+ },++ create(base?: DeepPartial<InstanceMetadata>): InstanceMetadata {+ return InstanceMetadata.fromPartial(base ?? {});+ },++ fromPartial(object: DeepPartial<InstanceMetadata>): InstanceMetadata {+ const message = createBaseInstanceMetadata();+ message.mysqlLowerCaseTableName = object.mysqlLowerCaseTableName ?? 0;+ return message;+ },+};+type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;export type DeepPartial<T> = T extends Builtin ? Tdiff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.mdindex 8d62062eaf..69389c2c49 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -68,6 +68,7 @@- [OAuth2AuthStyle](#bytebase-store-OAuth2AuthStyle)- [store/instance.proto](#store_instance-proto)+ - [InstanceMetadata](#bytebase-store-InstanceMetadata)- [InstanceOptions](#bytebase-store-InstanceOptions)- [store/vcs.proto](#store_vcs-proto)@@ -1087,6 +1088,21 @@ OIDCIdentityProviderConfig is the structure for OIDC identity provider config.+<a name="bytebase-store-InstanceMetadata"></a>++### InstanceMetadata+InstanceMetadata is the metadata for instances.+++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| mysql_lower_case_table_name | [int32](#int32) | | The lower_case_table_name config for MySQL instances. It is used to determine whether the table name and database name are case sensitive. |++++++<a name="bytebase-store-InstanceOptions"></a>### InstanceOptionsdiff --git a/proto/generated-go/store/instance.pb.go b/proto/generated-go/store/instance.pb.goindex 567594d67e..c618a36dcc 100644--- a/proto/generated-go/store/instance.pb.go+++ b/proto/generated-go/store/instance.pb.go@@ -70,6 +70,56 @@ func (x *InstanceOptions) GetSchemaTenantMode() bool {return false}+// InstanceMetadata is the metadata for instances.+type InstanceMetadata struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // The lower_case_table_name config for MySQL instances.+ // It is used to determine whether the table name and database name are case sensitive.+ MysqlLowerCaseTableName int32 `protobuf:"varint,1,opt,name=mysql_lower_case_table_name,json=mysqlLowerCaseTableName,proto3" json:"mysql_lower_case_table_name,omitempty"`+}++func (x *InstanceMetadata) Reset() {+ *x = InstanceMetadata{}+ if protoimpl.UnsafeEnabled {+ mi := &file_store_instance_proto_msgTypes[1]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *InstanceMetadata) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*InstanceMetadata) ProtoMessage() {}++func (x *InstanceMetadata) ProtoReflect() protoreflect.Message {+ mi := &file_store_instance_proto_msgTypes[1]+ if protoimpl.UnsafeEnabled && x != nil {+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ if ms.LoadMessageInfo() == nil {+ ms.StoreMessageInfo(mi)+ }+ return ms+ }+ return mi.MessageOf(x)+}++// Deprecated: Use InstanceMetadata.ProtoReflect.Descriptor instead.+func (*InstanceMetadata) Descriptor() ([]byte, []int) {+ return file_store_instance_proto_rawDescGZIP(), []int{1}+}++func (x *InstanceMetadata) GetMysqlLowerCaseTableName() int32 {+ if x != nil {+ return x.MysqlLowerCaseTableName+ }+ return 0+}+var File_store_instance_proto protoreflect.FileDescriptorvar file_store_instance_proto_rawDesc = []byte{@@ -79,9 +129,14 @@ var file_store_instance_proto_rawDesc = []byte{0x63, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x73, 0x63, 0x68,0x65, 0x6d, 0x61, 0x5f, 0x74, 0x65, 0x6e, 0x61, 0x6e, 0x74, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18,0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x54, 0x65, 0x6e,- 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e, 0x65, 0x72,- 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62, 0x06, 0x70,- 0x72, 0x6f, 0x74, 0x6f, 0x33,+ 0x61, 0x6e, 0x74, 0x4d, 0x6f, 0x64, 0x65, 0x22, 0x50, 0x0a, 0x10, 0x49, 0x6e, 0x73, 0x74, 0x61,+ 0x6e, 0x63, 0x65, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3c, 0x0a, 0x1b, 0x6d,+ 0x79, 0x73, 0x71, 0x6c, 0x5f, 0x6c, 0x6f, 0x77, 0x65, 0x72, 0x5f, 0x63, 0x61, 0x73, 0x65, 0x5f,+ 0x74, 0x61, 0x62, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,+ 0x52, 0x17, 0x6d, 0x79, 0x73, 0x71, 0x6c, 0x4c, 0x6f, 0x77, 0x65, 0x72, 0x43, 0x61, 0x73, 0x65,+ 0x54, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x14, 0x5a, 0x12, 0x67, 0x65, 0x6e,+ 0x65, 0x72, 0x61, 0x74, 0x65, 0x64, 0x2d, 0x67, 0x6f, 0x2f, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x62,+ 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,}var (@@ -96,9 +151,10 @@ func file_store_instance_proto_rawDescGZIP() []byte {return file_store_instance_proto_rawDescData}-var file_store_instance_proto_msgTypes = make([]protoimpl.MessageInfo, 1)+var file_store_instance_proto_msgTypes = make([]protoimpl.MessageInfo, 2)var file_store_instance_proto_goTypes = []interface{}{- (*InstanceOptions)(nil), // 0: bytebase.store.InstanceOptions+ (*InstanceOptions)(nil), // 0: bytebase.store.InstanceOptions+ (*InstanceMetadata)(nil), // 1: bytebase.store.InstanceMetadata}var file_store_instance_proto_depIdxs = []int32{0, // [0:0] is the sub-list for method output_type@@ -126,6 +182,18 @@ func file_store_instance_proto_init() {return nil}}+ file_store_instance_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {+ switch v := v.(*InstanceMetadata); i {+ case 0:+ return &v.state+ case 1:+ return &v.sizeCache+ case 2:+ return &v.unknownFields+ default:+ return nil+ }+ }}type x struct{}out := protoimpl.TypeBuilder{@@ -133,7 +201,7 @@ func file_store_instance_proto_init() {GoPackagePath: reflect.TypeOf(x{}).PkgPath(),RawDescriptor: file_store_instance_proto_rawDesc,NumEnums: 0,- NumMessages: 1,+ NumMessages: 2,NumExtensions: 0,NumServices: 0,},diff --git a/proto/store/instance.proto b/proto/store/instance.protoindex 1236efa49c..05a1f3dc2d 100644--- a/proto/store/instance.proto+++ b/proto/store/instance.proto@@ -10,3 +10,10 @@ message InstanceOptions {// For Oracle schema tenant mode, the instance a Oracle database and the database is the Oracle schema.bool schema_tenant_mode = 1;}++// InstanceMetadata is the metadata for instances.+message InstanceMetadata {+ // The lower_case_table_name config for MySQL instances.+ // It is used to determine whether the table name and database name are case sensitive.+ int32 mysql_lower_case_table_name = 1;+}