Skip to content

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

feat: add instance option column for instance (#6912)

rebeliceeef06378e1c9
diff --git a/backend/migrator/migration/dev/LATEST.sql b/backend/migrator/migration/dev/LATEST.sql
index 02ace1b335..ffd7de3417 100644
--- a/backend/migrator/migration/dev/LATEST.sql
+++ b/backend/migrator/migration/dev/LATEST.sql
@@ -332,7 +332,8 @@ CREATE TABLE instance (
external_link TEXT NOT NULL DEFAULT '',
resource_id TEXT NOT NULL,
-- activation should set to be TRUE if users assign license to this instance.
- activation BOOLEAN NOT NULL DEFAULT false
+ activation BOOLEAN NOT NULL DEFAULT false,
+ options JSONB NOT NULL DEFAULT '{}'
);
CREATE UNIQUE INDEX idx_instance_unique_resource_id ON instance(resource_id);
diff --git a/backend/migrator/migration/prod/2.4/0002##add_options_to_instance.sql b/backend/migrator/migration/prod/2.4/0002##add_options_to_instance.sql
new file mode 100644
index 0000000000..6229909cf4
--- /dev/null
+++ b/backend/migrator/migration/prod/2.4/0002##add_options_to_instance.sql
@@ -0,0 +1 @@
+ALTER TABLE instance ADD COLUMN options JSONB NOT NULL DEFAULT '{}';
\ No newline at end of file
diff --git a/backend/migrator/migration/prod/LATEST.sql b/backend/migrator/migration/prod/LATEST.sql
index d44ca6fd09..2c84bc6a94 100644
--- a/backend/migrator/migration/prod/LATEST.sql
+++ b/backend/migrator/migration/prod/LATEST.sql
@@ -331,7 +331,8 @@ CREATE TABLE instance (
external_link TEXT NOT NULL DEFAULT '',
resource_id TEXT NOT NULL,
-- activation should set to be TRUE if users assign license to this instance.
- activation BOOLEAN NOT NULL DEFAULT false
+ activation BOOLEAN NOT NULL DEFAULT false,
+ options 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.go
index aa598b7d58..122d944a4b 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.4.1"), releaseVersion)
+ require.Equal(t, semver.MustParse("2.4.2"), releaseVersion)
}
diff --git a/frontend/src/types/proto/store/instance.ts b/frontend/src/types/proto/store/instance.ts
new file mode 100644
index 0000000000..69f93e11dc
--- /dev/null
+++ b/frontend/src/types/proto/store/instance.ts
@@ -0,0 +1,80 @@
+/* eslint-disable */
+import * as _m0 from "protobufjs/minimal";
+
+export const protobufPackage = "bytebase.store";
+
+/** InstanceOptions is the option for instances. */
+export interface InstanceOptions {
+ /**
+ * The schema tenant mode is used to determine whether the instance is in schema tenant mode.
+ * For Oracle schema tenant mode, the instance a Oracle database and the database is the Oracle schema.
+ */
+ schemaTenantMode: boolean;
+}
+
+function createBaseInstanceOptions(): InstanceOptions {
+ return { schemaTenantMode: false };
+}
+
+export const InstanceOptions = {
+ encode(message: InstanceOptions, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
+ if (message.schemaTenantMode === true) {
+ writer.uint32(8).bool(message.schemaTenantMode);
+ }
+ return writer;
+ },
+
+ decode(input: _m0.Reader | Uint8Array, length?: number): InstanceOptions {
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
+ let end = length === undefined ? reader.len : reader.pos + length;
+ const message = createBaseInstanceOptions();
+ while (reader.pos < end) {
+ const tag = reader.uint32();
+ switch (tag >>> 3) {
+ case 1:
+ if (tag !== 8) {
+ break;
+ }
+
+ message.schemaTenantMode = reader.bool();
+ continue;
+ }
+ if ((tag & 7) === 4 || tag === 0) {
+ break;
+ }
+ reader.skipType(tag & 7);
+ }
+ return message;
+ },
+
+ fromJSON(object: any): InstanceOptions {
+ return { schemaTenantMode: isSet(object.schemaTenantMode) ? Boolean(object.schemaTenantMode) : false };
+ },
+
+ toJSON(message: InstanceOptions): unknown {
+ const obj: any = {};
+ message.schemaTenantMode !== undefined && (obj.schemaTenantMode = message.schemaTenantMode);
+ return obj;
+ },
+
+ create(base?: DeepPartial<InstanceOptions>): InstanceOptions {
+ return InstanceOptions.fromPartial(base ?? {});
+ },
+
+ fromPartial(object: DeepPartial<InstanceOptions>): InstanceOptions {
+ const message = createBaseInstanceOptions();
+ message.schemaTenantMode = object.schemaTenantMode ?? false;
+ return message;
+ },
+};
+
+type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
+
+export type DeepPartial<T> = T extends Builtin ? T
+ : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
+ : Partial<T>;
+
+function isSet(value: any): boolean {
+ return value !== null && value !== undefined;
+}
diff --git a/proto/gen/grpc-doc/store/README.md b/proto/gen/grpc-doc/store/README.md
index 416d7420d6..13e65bc03c 100644
--- a/proto/gen/grpc-doc/store/README.md
+++ b/proto/gen/grpc-doc/store/README.md
@@ -64,6 +64,9 @@
- [IdentityProviderType](#bytebase-store-IdentityProviderType)
+- [store/instance.proto](#store_instance-proto)
+ - [InstanceOptions](#bytebase-store-InstanceOptions)
+
- [store/vcs.proto](#store_vcs-proto)
- [Commit](#bytebase-store-Commit)
- [FileCommit](#bytebase-store-FileCommit)
@@ -1012,6 +1015,37 @@ OIDCIdentityProviderConfig is the structure for OIDC identity provider config.
+<a name="store_instance-proto"></a>
+<p align="right"><a href="#top">Top</a></p>
+
+## store/instance.proto
+
+
+
+<a name="bytebase-store-InstanceOptions"></a>
+
+### InstanceOptions
+InstanceOptions is the option for instances.
+
+
+| Field | Type | Label | Description |
+| ----- | ---- | ----- | ----------- |
+| schema_tenant_mode | [bool](#bool) | | The schema tenant mode is used to determine whether the instance is in schema tenant mode. For Oracle schema tenant mode, the instance a Oracle database and the database is the Oracle schema. |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<a name="store_vcs-proto"></a>
<p align="right"><a href="#top">Top</a></p>
diff --git a/proto/generated-go/store/instance.pb.go b/proto/generated-go/store/instance.pb.go
new file mode 100644
index 0000000000..567594d67e
--- /dev/null
+++ b/proto/generated-go/store/instance.pb.go
@@ -0,0 +1,148 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.31.0
+// protoc (unknown)
+// source: store/instance.proto
+
+package store
+
+import (
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
+ reflect "reflect"
+ sync "sync"
+)
+
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
+
+// InstanceOptions is the option for instances.
+type InstanceOptions struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
+
+ // The schema tenant mode is used to determine whether the instance is in schema tenant mode.
+ // For Oracle schema tenant mode, the instance a Oracle database and the database is the Oracle schema.
+ SchemaTenantMode bool `protobuf:"varint,1,opt,name=schema_tenant_mode,json=schemaTenantMode,proto3" json:"schema_tenant_mode,omitempty"`
+}
+
+func (x *InstanceOptions) Reset() {
+ *x = InstanceOptions{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_store_instance_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
+}
+
+func (x *InstanceOptions) String() string {
+ return protoimpl.X.MessageStringOf(x)
+}
+
+func (*InstanceOptions) ProtoMessage() {}
+
+func (x *InstanceOptions) ProtoReflect() protoreflect.Message {
+ mi := &file_store_instance_proto_msgTypes[0]
+ 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 InstanceOptions.ProtoReflect.Descriptor instead.
+func (*InstanceOptions) Descriptor() ([]byte, []int) {
+ return file_store_instance_proto_rawDescGZIP(), []int{0}
+}
+
+func (x *InstanceOptions) GetSchemaTenantMode() bool {
+ if x != nil {
+ return x.SchemaTenantMode
+ }
+ return false
+}
+
+var File_store_instance_proto protoreflect.FileDescriptor
+
+var file_store_instance_proto_rawDesc = []byte{
+ 0x0a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65,
+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,
+ 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x22, 0x3f, 0x0a, 0x0f, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e,
+ 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,
+}
+
+var (
+ file_store_instance_proto_rawDescOnce sync.Once
+ file_store_instance_proto_rawDescData = file_store_instance_proto_rawDesc
+)
+
+func file_store_instance_proto_rawDescGZIP() []byte {
+ file_store_instance_proto_rawDescOnce.Do(func() {
+ file_store_instance_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_instance_proto_rawDescData)
+ })
+ return file_store_instance_proto_rawDescData
+}
+
+var file_store_instance_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
+var file_store_instance_proto_goTypes = []interface{}{
+ (*InstanceOptions)(nil), // 0: bytebase.store.InstanceOptions
+}
+var file_store_instance_proto_depIdxs = []int32{
+ 0, // [0:0] is the sub-list for method output_type
+ 0, // [0:0] is the sub-list for method input_type
+ 0, // [0:0] is the sub-list for extension type_name
+ 0, // [0:0] is the sub-list for extension extendee
+ 0, // [0:0] is the sub-list for field type_name
+}
+
+func init() { file_store_instance_proto_init() }
+func file_store_instance_proto_init() {
+ if File_store_instance_proto != nil {
+ return
+ }
+ if !protoimpl.UnsafeEnabled {
+ file_store_instance_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*InstanceOptions); 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{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_store_instance_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 1,
+ NumExtensions: 0,
+ NumServices: 0,
+ },
+ GoTypes: file_store_instance_proto_goTypes,
+ DependencyIndexes: file_store_instance_proto_depIdxs,
+ MessageInfos: file_store_instance_proto_msgTypes,
+ }.Build()
+ File_store_instance_proto = out.File
+ file_store_instance_proto_rawDesc = nil
+ file_store_instance_proto_goTypes = nil
+ file_store_instance_proto_depIdxs = nil
+}
diff --git a/proto/store/instance.proto b/proto/store/instance.proto
new file mode 100644
index 0000000000..1236efa49c
--- /dev/null
+++ b/proto/store/instance.proto
@@ -0,0 +1,12 @@
+syntax = "proto3";
+
+package bytebase.store;
+
+option go_package = "generated-go/store";
+
+// InstanceOptions is the option for instances.
+message InstanceOptions {
+ // The schema tenant mode is used to determine whether the instance is in schema tenant mode.
+ // For Oracle schema tenant mode, the instance a Oracle database and the database is the Oracle schema.
+ bool schema_tenant_mode = 1;
+}