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: revision (#13902)
p0ny1ad2045c99ed
diff --git a/backend/api/v1/database_service_revision.go b/backend/api/v1/database_service_revision.gonew file mode 100644index 0000000000..f66a364dc3--- /dev/null+++ b/backend/api/v1/database_service_revision.go@@ -0,0 +1,112 @@+package v1++import (+ "context"+ "fmt"++ "google.golang.org/grpc/codes"+ "google.golang.org/grpc/status"+ "google.golang.org/protobuf/types/known/timestamppb"++ "github.com/pkg/errors"++ "github.com/bytebase/bytebase/backend/common"+ "github.com/bytebase/bytebase/backend/store"+ v1pb "github.com/bytebase/bytebase/proto/generated-go/v1"+)++func (s *DatabaseService) ListRevisions(ctx context.Context, request *v1pb.ListRevisionsRequest) (*v1pb.ListRevisionsResponse, error) {+ instanceID, databaseID, err := common.GetInstanceDatabaseID(request.Parent)+ if err != nil {+ return nil, status.Errorf(codes.InvalidArgument, "failed to get instance and database from %v, err: %v", request.Parent, err)+ }++ instance, err := s.store.GetInstanceV2(ctx, &store.FindInstanceMessage{ResourceID: &instanceID})+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to find instance %v, err: %v", instanceID, err)+ }+ if instance == nil {+ return nil, status.Errorf(codes.NotFound, "instance %v not found", instanceID)+ }++ database, err := s.store.GetDatabaseV2(ctx, &store.FindDatabaseMessage{+ InstanceID: &instanceID,+ DatabaseName: &databaseID,+ })+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to find database %v, err: %v", request.Parent, err)+ }+ if database == nil {+ return nil, status.Errorf(codes.NotFound, "database %v not found", request.Parent)+ }++ limit, offset, err := parseLimitAndOffset(request.PageToken, int(request.PageSize))+ if err != nil {+ return nil, err+ }+ limitPlusOne := limit + 1++ find := &store.FindRevisionMessage{+ DatabaseUID: database.UID,+ InstanceUID: instance.UID,+ Limit: &limitPlusOne,+ Offset: &offset,+ }++ revisions, err := s.store.ListRevisions(ctx, find)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to find revisions, err: %v", err)+ }++ var nextPageToken string+ if len(revisions) == limitPlusOne {+ pageToken, err := getPageToken(limit, offset+limit)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to get next page token, error: %v", err)+ }+ nextPageToken = pageToken+ revisions = revisions[:limit]+ }++ converted, err := convertToRevisions(ctx, s.store, request.Parent, revisions)+ if err != nil {+ return nil, status.Errorf(codes.Internal, "failed to convert to revisions, err: %v", err)+ }++ return &v1pb.ListRevisionsResponse{+ Revisions: converted,+ NextPageToken: nextPageToken,+ }, nil+}++func convertToRevisions(ctx context.Context, s *store.Store, parent string, revisions []*store.RevisionMessage) ([]*v1pb.Revision, error) {+ var rs []*v1pb.Revision+ for _, revision := range revisions {+ r, err := convertToRevision(ctx, s, parent, revision)+ if err != nil {+ return nil, errors.Wrapf(err, "failed to convert to revisions")+ }+ rs = append(rs, r)+ }+ return rs, nil+}++func convertToRevision(ctx context.Context, s *store.Store, parent string, revision *store.RevisionMessage) (*v1pb.Revision, error) {+ creator, err := s.GetUserByID(ctx, revision.CreatorUID)+ if err != nil {+ return nil, errors.Wrapf(err, "failed to get creator")+ }++ return &v1pb.Revision{+ Name: fmt.Sprintf("%s/%s%d", parent, common.RevisionNamePrefix, revision.UID),+ Release: revision.Payload.Release,+ CreateTime: timestamppb.New(revision.CreatedTime),+ Creator: common.FormatUserEmail(creator.Email),+ Sheet: revision.Payload.Sheet,+ SheetSha1: revision.Payload.SheetSha1,+ Type: v1pb.ReleaseFileType(revision.Payload.Type),+ Version: revision.Payload.Version,+ File: revision.Payload.File,+ TaskRun: revision.Payload.TaskRun,+ }, nil+}diff --git a/backend/api/v1/release_service.go b/backend/api/v1/release_service.goindex dc1f6a0418..66ac015e68 100644--- a/backend/api/v1/release_service.go+++ b/backend/api/v1/release_service.go@@ -2,7 +2,6 @@ package v1import ("context"- "time""github.com/pkg/errors""google.golang.org/grpc/codes"@@ -145,7 +144,7 @@ func convertToReleases(ctx context.Context, s *store.Store, releases []*store.Refunc convertToRelease(ctx context.Context, s *store.Store, release *store.ReleaseMessage) (*v1pb.Release, error) {r := &v1pb.Release{Title: release.Payload.Title,- CreateTime: timestamppb.New(time.Unix(release.CreatedTs, 0)),+ CreateTime: timestamppb.New(release.CreatedTime),Files: convertToReleaseFiles(release.Payload.Files),VcsSource: convertToReleaseVcsSource(release.Payload.VcsSource),}diff --git a/backend/common/resource_name.go b/backend/common/resource_name.goindex 9b3072cf53..c2927d1a75 100644--- a/backend/common/resource_name.go+++ b/backend/common/resource_name.go@@ -50,6 +50,7 @@ const (GroupPrefix = "groups/"ReviewConfigPrefix = "reviewConfigs/"ReleaseNamePrefix = "releases/"+ RevisionNamePrefix = "revisions/"SchemaSuffix = "/schema"MetadataSuffix = "/metadata"diff --git a/backend/migrator/migration/dev/20240924000000##release.sql b/backend/migrator/migration/dev/20240924000000##release.sqlindex 3a7b52e3e7..4ad88803c0 100644--- a/backend/migrator/migration/dev/20240924000000##release.sql+++ b/backend/migrator/migration/dev/20240924000000##release.sql@@ -1,7 +1,7 @@-CREATE TABLE release (+CREATE TABLE IF NOT EXISTS release (id BIGSERIAL PRIMARY KEY,project_id INTEGER NOT NULL REFERENCES project (id),creator_id INTEGER NOT NULL REFERENCES principal (id),- created_ts BIGINT NOT NULL DEFAULT extract(epoch from now()),+ created_ts TIMESTAMPTZ NOT NULL DEFAULT now(),payload JSONB NOT NULL DEFAULT '{}');\ No newline at end of filediff --git a/backend/migrator/migration/dev/2024092400001##revision.sql b/backend/migrator/migration/dev/2024092400001##revision.sqlnew file mode 100644index 0000000000..87d82a06f0--- /dev/null+++ b/backend/migrator/migration/dev/2024092400001##revision.sql@@ -0,0 +1,8 @@+CREATE TABLE IF NOT EXISTS revision (+ id BIGSERIAL PRIMARY KEY,+ instance_id INTEGER NOT NULL REFERENCES instance (id),+ database_id INTEGER NOT NULL REFERENCES db (id),+ creator_id INTEGER NOT NULL REFERENCES principal (id),+ created_ts TIMESTAMPTZ NOT NULL DEFAULT now(),+ payload JSONB NOT NULL DEFAULT '{}'+);\ No newline at end of filediff --git a/backend/store/release.go b/backend/store/release.goindex 383d04323a..e1b2fe918d 100644--- a/backend/store/release.go+++ b/backend/store/release.go@@ -4,6 +4,7 @@ import ("context""database/sql""fmt"+ "time""github.com/pkg/errors""google.golang.org/protobuf/encoding/protojson"@@ -17,9 +18,9 @@ type ReleaseMessage struct {Payload *storepb.ReleasePayload// output only- UID int64- CreatorUID int- CreatedTs int64+ UID int64+ CreatorUID int+ CreatedTime time.Time}type FindReleaseMessage struct {@@ -52,12 +53,13 @@ func (s *Store) CreateRelease(ctx context.Context, release *ReleaseMessage, crea}defer tx.Rollback()- var id, createdTs int64+ var id int64+ var createdTime time.Timeif err := tx.QueryRowContext(ctx, query,creatorUID,release.ProjectUID,p,- ).Scan(&id, &createdTs); err != nil {+ ).Scan(&id, &createdTime); err != nil {return nil, errors.Wrapf(err, "failed to insert release")}@@ -67,7 +69,7 @@ func (s *Store) CreateRelease(ctx context.Context, release *ReleaseMessage, crearelease.UID = idrelease.CreatorUID = creatorUID- release.CreatedTs = createdTs+ release.CreatedTime = createdTimereturn release, nil}@@ -113,7 +115,7 @@ func (s *Store) ListReleases(ctx context.Context, find *FindReleaseMessage) ([]*&r.UID,&r.ProjectUID,&r.CreatorUID,- &r.CreatedTs,+ &r.CreatedTime,&payload,); err != nil {return nil, errors.Wrapf(err, "failed to scan rows")diff --git a/backend/store/revision.go b/backend/store/revision.gonew file mode 100644index 0000000000..0834b1f378--- /dev/null+++ b/backend/store/revision.go@@ -0,0 +1,150 @@+package store++import (+ "context"+ "database/sql"+ "fmt"+ "time"++ "github.com/pkg/errors"+ "google.golang.org/protobuf/encoding/protojson"++ "github.com/bytebase/bytebase/backend/common"+ storepb "github.com/bytebase/bytebase/proto/generated-go/store"+)++type RevisionMessage struct {+ InstanceUID int+ DatabaseUID int++ Payload *storepb.RevisionPayload++ // output only+ UID int64+ CreatorUID int+ CreatedTime time.Time+}++type FindRevisionMessage struct {+ InstanceUID int+ DatabaseUID int++ Limit *int+ Offset *int+}++func (s *Store) ListRevisions(ctx context.Context, find *FindRevisionMessage) ([]*RevisionMessage, error) {+ query := `+ SELECT+ id,+ instance_id,+ database_id,+ creator_id,+ created_ts,+ payload+ FROM revision+ WHERE instance_id = $1+ AND database_id = $2+ `++ if v := find.Limit; v != nil {+ query += fmt.Sprintf(" LIMIT %d", *v)+ }+ if v := find.Offset; v != nil {+ query += fmt.Sprintf(" OFFSET %d", *v)+ }++ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})+ if err != nil {+ return nil, errors.Wrapf(err, "failed to begin tx")+ }+ defer tx.Rollback()++ rows, err := tx.QueryContext(ctx, query, find.InstanceUID, find.DatabaseUID)+ if err != nil {+ return nil, errors.Wrapf(err, "failed to query context")+ }+ defer rows.Close()++ var revisions []*RevisionMessage+ for rows.Next() {+ r := RevisionMessage{+ Payload: &storepb.RevisionPayload{},+ }+ var p []byte+ if err := rows.Scan(+ &r.UID,+ &r.InstanceUID,+ &r.DatabaseUID,+ &r.CreatorUID,+ &r.CreatedTime,+ &p,+ ); err != nil {+ return nil, errors.Wrapf(err, "failed to scan")+ }++ if err := common.ProtojsonUnmarshaler.Unmarshal(p, r.Payload); err != nil {+ return nil, errors.Wrapf(err, "failed to unmarshal")+ }++ revisions = append(revisions, &r)+ }++ if err := rows.Err(); err != nil {+ return nil, errors.Wrapf(err, "rows err")+ }++ if err := tx.Commit(); err != nil {+ return nil, errors.Wrapf(err, "failed to commit tx")+ }++ return revisions, nil+}++func (s *Store) CreateRevision(ctx context.Context, revision *RevisionMessage, creatorUID int) (*RevisionMessage, error) {+ query := `+ INSERT INTO revision (+ instance_id,+ database_id,+ creator_id,+ payload+ ) VALUES (+ $1,+ $2,+ $3,+ $4+ )+ RETURNING id, created_ts+ `++ p, err := protojson.Marshal(revision.Payload)+ if err != nil {+ return nil, errors.Wrapf(err, "failed to marshal revision payload")+ }++ tx, err := s.db.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})+ if err != nil {+ return nil, errors.Wrapf(err, "failed to begin tx")+ }+ defer tx.Rollback()++ var id int64+ var createdTime time.Time+ if err := tx.QueryRowContext(ctx, query,+ revision.InstanceUID,+ revision.DatabaseUID,+ creatorUID,+ p,+ ).Scan(&id, &createdTime); err != nil {+ return nil, errors.Wrapf(err, "failed to query and scan")+ }++ if err := tx.Commit(); err != nil {+ return nil, errors.Wrapf(err, "failed to commit tx")+ }++ revision.UID = id+ revision.CreatedTime = createdTime++ return revision, nil+}diff --git a/frontend/src/types/proto/store/revision.ts b/frontend/src/types/proto/store/revision.tsnew file mode 100644index 0000000000..982544ac7b--- /dev/null+++ b/frontend/src/types/proto/store/revision.ts@@ -0,0 +1,208 @@+/* eslint-disable */+import Long from "long";+import _m0 from "protobufjs/minimal";+import { ReleaseFileType, releaseFileTypeFromJSON, releaseFileTypeToJSON, releaseFileTypeToNumber } from "./release";++export const protobufPackage = "bytebase.store";++export interface RevisionPayload {+ /**+ * Format: projects/{project}/releases/{release}+ * Can be empty.+ */+ release: string;+ /**+ * The sheet that holds the content.+ * Format: projects/{project}/sheets/{sheet}+ */+ sheet: string;+ /** The SHA1 hash value of the sheet. */+ sheetSha1: string;+ type: ReleaseFileType;+ version: string;+ /**+ * The name of the file in the release.+ * Expressed as a path, e.g. `2.2/V0001_create_table.sql`+ * Can be empty.+ */+ file: string;+ /**+ * The task run associated with the revision.+ * Can be empty.+ */+ taskRun: string;+}++function createBaseRevisionPayload(): RevisionPayload {+ return {+ release: "",+ sheet: "",+ sheetSha1: "",+ type: ReleaseFileType.TYPE_UNSPECIFIED,+ version: "",+ file: "",+ taskRun: "",+ };+}++export const RevisionPayload = {+ encode(message: RevisionPayload, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {+ if (message.release !== "") {+ writer.uint32(10).string(message.release);+ }+ if (message.sheet !== "") {+ writer.uint32(18).string(message.sheet);+ }+ if (message.sheetSha1 !== "") {+ writer.uint32(26).string(message.sheetSha1);+ }+ if (message.type !== ReleaseFileType.TYPE_UNSPECIFIED) {+ writer.uint32(32).int32(releaseFileTypeToNumber(message.type));+ }+ if (message.version !== "") {+ writer.uint32(42).string(message.version);+ }+ if (message.file !== "") {+ writer.uint32(50).string(message.file);+ }+ if (message.taskRun !== "") {+ writer.uint32(58).string(message.taskRun);+ }+ return writer;+ },++ decode(input: _m0.Reader | Uint8Array, length?: number): RevisionPayload {+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);+ let end = length === undefined ? reader.len : reader.pos + length;+ const message = createBaseRevisionPayload();+ while (reader.pos < end) {+ const tag = reader.uint32();+ switch (tag >>> 3) {+ case 1:+ if (tag !== 10) {+ break;+ }++ message.release = reader.string();+ continue;+ case 2:+ if (tag !== 18) {+ break;+ }++ message.sheet = reader.string();+ continue;+ case 3:+ if (tag !== 26) {+ break;+ }++ message.sheetSha1 = reader.string();+ continue;+ case 4:+ if (tag !== 32) {+ break;+ }++ message.type = releaseFileTypeFromJSON(reader.int32());+ continue;+ case 5:+ if (tag !== 42) {+ break;+ }++ message.version = reader.string();+ continue;+ case 6:+ if (tag !== 50) {+ break;+ }++ message.file = reader.string();+ continue;+ case 7:+ if (tag !== 58) {+ break;+ }++ message.taskRun = reader.string();+ continue;+ }+ if ((tag & 7) === 4 || tag === 0) {+ break;+ }+ reader.skipType(tag & 7);+ }+ return message;+ },++ fromJSON(object: any): RevisionPayload {+ return {+ release: isSet(object.release) ? globalThis.String(object.release) : "",+ sheet: isSet(object.sheet) ? globalThis.String(object.sheet) : "",+ sheetSha1: isSet(object.sheetSha1) ? globalThis.String(object.sheetSha1) : "",+ type: isSet(object.type) ? releaseFileTypeFromJSON(object.type) : ReleaseFileType.TYPE_UNSPECIFIED,+ version: isSet(object.version) ? globalThis.String(object.version) : "",+ file: isSet(object.file) ? globalThis.String(object.file) : "",+ taskRun: isSet(object.taskRun) ? globalThis.String(object.taskRun) : "",+ };+ },++ toJSON(message: RevisionPayload): unknown {+ const obj: any = {};+ if (message.release !== "") {+ obj.release = message.release;+ }+ if (message.sheet !== "") {+ obj.sheet = message.sheet;+ }+ if (message.sheetSha1 !== "") {+ obj.sheetSha1 = message.sheetSha1;+ }+ if (message.type !== ReleaseFileType.TYPE_UNSPECIFIED) {+ obj.type = releaseFileTypeToJSON(message.type);+ }+ if (message.version !== "") {+ obj.version = message.version;+ }+ if (message.file !== "") {+ obj.file = message.file;+ }+ if (message.taskRun !== "") {+ obj.taskRun = message.taskRun;+ }+ return obj;+ },++ create(base?: DeepPartial<RevisionPayload>): RevisionPayload {+ return RevisionPayload.fromPartial(base ?? {});+ },+ fromPartial(object: DeepPartial<RevisionPayload>): RevisionPayload {+ const message = createBaseRevisionPayload();+ message.release = object.release ?? "";+ message.sheet = object.sheet ?? "";+ message.sheetSha1 = object.sheetSha1 ?? "";+ message.type = object.type ?? ReleaseFileType.TYPE_UNSPECIFIED;+ message.version = object.version ?? "";+ message.file = object.file ?? "";+ message.taskRun = object.taskRun ?? "";+ return message;+ },+};++type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;++export type DeepPartial<T> = T extends Builtin ? T+ : T extends Long ? string | number | Long : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>>+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }+ : Partial<T>;++if (_m0.util.Long !== Long) {+ _m0.util.Long = Long as any;+ _m0.configure();+}++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.mdindex 283da2098b..7c2fe1da62 100644--- a/proto/gen/grpc-doc/store/README.md+++ b/proto/gen/grpc-doc/store/README.md@@ -231,6 +231,9 @@- [store/review_config.proto](#store_review_config-proto)- [ReviewConfigPayload](#bytebase-store-ReviewConfigPayload)+- [store/revision.proto](#store_revision-proto)+ - [RevisionPayload](#bytebase-store-RevisionPayload)+- [store/role.proto](#store_role-proto)- [RolePermissions](#bytebase-store-RolePermissions)@@ -3591,6 +3594,43 @@ SlowQueryPolicy is the policy configuration for slow query.+<a name="store_revision-proto"></a>+<p align="right"><a href="#top">Top</a></p>++## store/revision.proto++++<a name="bytebase-store-RevisionPayload"></a>++### RevisionPayload++++| Field | Type | Label | Description |+| ----- | ---- | ----- | ----------- |+| release | [string](#string) | | Format: projects/{project}/releases/{release} Can be empty. |+| sheet | [string](#string) | | The sheet that holds the content. Format: projects/{project}/sheets/{sheet} |+| sheet_sha1 | [string](#string) | | The SHA1 hash value of the sheet. |+| type | [ReleaseFileType](#bytebase-store-ReleaseFileType) | | |+| version | [string](#string) | | |+| file | [string](#string) | | The name of the file in the release. Expressed as a path, e.g. `2.2/V0001_create_table.sql` Can be empty. |+| task_run | [string](#string) | | The task run associated with the revision. Can be empty. |+++++++++++++++<a name="store_role-proto"></a><p align="right"><a href="#top">Top</a></p>diff --git a/proto/gen/grpc-doc/store/index.html b/proto/gen/grpc-doc/store/index.htmlindex cbbfdc742d..17482e6501 100644--- a/proto/gen/grpc-doc/store/index.html+++ b/proto/gen/grpc-doc/store/index.html@@ -1105,6 +1105,21 @@+ </ul>+ </li>+++ <li>+ <a href="#store%2frevision.proto">store/revision.proto</a>+ <ul>++ <li>+ <a href="#bytebase.store.RevisionPayload"><span class="badge">M</span>RevisionPayload</a>+ </li>++++</ul></li>@@ -9071,6 +9086,91 @@ Format: projects/{project}/sheets/{sheet} </p></td>+ <div class="file-heading">+ <h2 id="store/revision.proto">store/revision.proto</h2><a href="#title">Top</a>+ </div>+ <p></p>+++ <h3 id="bytebase.store.RevisionPayload">RevisionPayload</h3>+ <p></p>+++ <table class="field-table">+ <thead>+ <tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>+ </thead>+ <tbody>++ <tr>+ <td>release</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>Format: projects/{project}/releases/{release}+Can be empty. </p></td>+ </tr>++ <tr>+ <td>sheet</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The sheet that holds the content.+Format: projects/{project}/sheets/{sheet} </p></td>+ </tr>++ <tr>+ <td>sheet_sha1</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The SHA1 hash value of the sheet. </p></td>+ </tr>++ <tr>+ <td>type</td>+ <td><a href="#bytebase.store.ReleaseFileType">ReleaseFileType</a></td>+ <td></td>+ <td><p> </p></td>+ </tr>++ <tr>+ <td>version</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p> </p></td>+ </tr>++ <tr>+ <td>file</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The name of the file in the release.+Expressed as a path, e.g. `2.2/V0001_create_table.sql`+Can be empty. </p></td>+ </tr>++ <tr>+ <td>task_run</td>+ <td><a href="#string">string</a></td>+ <td></td>+ <td><p>The task run associated with the revision.+Can be empty. </p></td>+ </tr>++ </tbody>+ </table>+++++++++++++<div class="file-heading"><h2 id="store/role.proto">store/role.proto</h2><a href="#title">Top</a></div>diff --git a/proto/generated-go/store/revision.pb.go b/proto/generated-go/store/revision.pb.gonew file mode 100644index 0000000000..eda4a029d1--- /dev/null+++ b/proto/generated-go/store/revision.pb.go@@ -0,0 +1,225 @@+// Code generated by protoc-gen-go. DO NOT EDIT.+// versions:+// protoc-gen-go v1.34.2+// protoc (unknown)+// source: store/revision.proto++package store++import (+ _ "google.golang.org/genproto/googleapis/api/annotations"+ 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)+)++type RevisionPayload struct {+ state protoimpl.MessageState+ sizeCache protoimpl.SizeCache+ unknownFields protoimpl.UnknownFields++ // Format: projects/{project}/releases/{release}+ // Can be empty.+ Release string `protobuf:"bytes,1,opt,name=release,proto3" json:"release,omitempty"`+ // The sheet that holds the content.+ // Format: projects/{project}/sheets/{sheet}+ Sheet string `protobuf:"bytes,2,opt,name=sheet,proto3" json:"sheet,omitempty"`+ // The SHA1 hash value of the sheet.+ SheetSha1 string `protobuf:"bytes,3,opt,name=sheet_sha1,json=sheetSha1,proto3" json:"sheet_sha1,omitempty"`+ Type ReleaseFileType `protobuf:"varint,4,opt,name=type,proto3,enum=bytebase.store.ReleaseFileType" json:"type,omitempty"`+ Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"`+ // The name of the file in the release.+ // Expressed as a path, e.g. `2.2/V0001_create_table.sql`+ // Can be empty.+ File string `protobuf:"bytes,6,opt,name=file,proto3" json:"file,omitempty"`+ // The task run associated with the revision.+ // Can be empty.+ TaskRun string `protobuf:"bytes,7,opt,name=task_run,json=taskRun,proto3" json:"task_run,omitempty"`+}++func (x *RevisionPayload) Reset() {+ *x = RevisionPayload{}+ if protoimpl.UnsafeEnabled {+ mi := &file_store_revision_proto_msgTypes[0]+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))+ ms.StoreMessageInfo(mi)+ }+}++func (x *RevisionPayload) String() string {+ return protoimpl.X.MessageStringOf(x)+}++func (*RevisionPayload) ProtoMessage() {}++func (x *RevisionPayload) ProtoReflect() protoreflect.Message {+ mi := &file_store_revision_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 RevisionPayload.ProtoReflect.Descriptor instead.+func (*RevisionPayload) Descriptor() ([]byte, []int) {+ return file_store_revision_proto_rawDescGZIP(), []int{0}+}++func (x *RevisionPayload) GetRelease() string {+ if x != nil {+ return x.Release+ }+ return ""+}++func (x *RevisionPayload) GetSheet() string {+ if x != nil {+ return x.Sheet+ }+ return ""+}++func (x *RevisionPayload) GetSheetSha1() string {+ if x != nil {+ return x.SheetSha1+ }+ return ""+}++func (x *RevisionPayload) GetType() ReleaseFileType {+ if x != nil {+ return x.Type+ }+ return ReleaseFileType_TYPE_UNSPECIFIED+}++func (x *RevisionPayload) GetVersion() string {+ if x != nil {+ return x.Version+ }+ return ""+}++func (x *RevisionPayload) GetFile() string {+ if x != nil {+ return x.File+ }+ return ""+}++func (x *RevisionPayload) GetTaskRun() string {+ if x != nil {+ return x.TaskRun+ }+ return ""+}++var File_store_revision_proto protoreflect.FileDescriptor++var file_store_revision_proto_rawDesc = []byte{+ 0x0a, 0x14, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x65, 0x76, 0x69, 0x73, 0x69, 0x6f, 0x6e,+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0e, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65,+ 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61,+ 0x70, 0x69, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,+ 0x6f, 0x1a, 0x13, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,+ 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xad, 0x02, 0x0a, 0x0f, 0x52, 0x65, 0x76, 0x69, 0x73,+ 0x69, 0x6f, 0x6e, 0x50, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x33, 0x0a, 0x07, 0x72, 0x65,+ 0x6c, 0x65, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x19, 0xfa, 0x41, 0x16,+ 0x0a, 0x14, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x52,+ 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x52, 0x07, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12,+ 0x2d, 0x0a, 0x05, 0x73, 0x68, 0x65, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x42, 0x17,+ 0xfa, 0x41, 0x14, 0x0a, 0x12, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x63, 0x6f,+ 0x6d, 0x2f, 0x53, 0x68, 0x65, 0x65, 0x74, 0x52, 0x05, 0x73, 0x68, 0x65, 0x65, 0x74, 0x12, 0x1d,+ 0x0a, 0x0a, 0x73, 0x68, 0x65, 0x65, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x31, 0x18, 0x03, 0x20, 0x01,+ 0x28, 0x09, 0x52, 0x09, 0x73, 0x68, 0x65, 0x65, 0x74, 0x53, 0x68, 0x61, 0x31, 0x12, 0x33, 0x0a,+ 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1f, 0x2e, 0x62, 0x79,+ 0x74, 0x65, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x2e, 0x52, 0x65, 0x6c,+ 0x65, 0x61, 0x73, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79,+ 0x70, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05, 0x20,+ 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x12, 0x0a, 0x04,+ 0x66, 0x69, 0x6c, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65,+ 0x12, 0x34, 0x0a, 0x08, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x72, 0x75, 0x6e, 0x18, 0x07, 0x20, 0x01,+ 0x28, 0x09, 0x42, 0x19, 0xfa, 0x41, 0x16, 0x0a, 0x14, 0x62, 0x79, 0x74, 0x65, 0x62, 0x61, 0x73,+ 0x65, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x75, 0x6e, 0x52, 0x07, 0x74,+ 0x61, 0x73, 0x6b, 0x52, 0x75, 0x6e, 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_revision_proto_rawDescOnce sync.Once+ file_store_revision_proto_rawDescData = file_store_revision_proto_rawDesc+)++func file_store_revision_proto_rawDescGZIP() []byte {+ file_store_revision_proto_rawDescOnce.Do(func() {+ file_store_revision_proto_rawDescData = protoimpl.X.CompressGZIP(file_store_revision_proto_rawDescData)+ })+ return file_store_revision_proto_rawDescData+}++var file_store_revision_proto_msgTypes = make([]protoimpl.MessageInfo, 1)+var file_store_revision_proto_goTypes = []any{+ (*RevisionPayload)(nil), // 0: bytebase.store.RevisionPayload+ (ReleaseFileType)(0), // 1: bytebase.store.ReleaseFileType+}+var file_store_revision_proto_depIdxs = []int32{+ 1, // 0: bytebase.store.RevisionPayload.type:type_name -> bytebase.store.ReleaseFileType+ 1, // [1:1] is the sub-list for method output_type+ 1, // [1:1] is the sub-list for method input_type+ 1, // [1:1] is the sub-list for extension type_name+ 1, // [1:1] is the sub-list for extension extendee+ 0, // [0:1] is the sub-list for field type_name+}++func init() { file_store_revision_proto_init() }+func file_store_revision_proto_init() {+ if File_store_revision_proto != nil {+ return+ }+ file_store_release_proto_init()+ if !protoimpl.UnsafeEnabled {+ file_store_revision_proto_msgTypes[0].Exporter = func(v any, i int) any {+ switch v := v.(*RevisionPayload); 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_revision_proto_rawDesc,+ NumEnums: 0,+ NumMessages: 1,+ NumExtensions: 0,+ NumServices: 0,+ },+ GoTypes: file_store_revision_proto_goTypes,+ DependencyIndexes: file_store_revision_proto_depIdxs,+ MessageInfos: file_store_revision_proto_msgTypes,+ }.Build()+ File_store_revision_proto = out.File+ file_store_revision_proto_rawDesc = nil+ file_store_revision_proto_goTypes = nil+ file_store_revision_proto_depIdxs = nil+}diff --git a/proto/store/revision.proto b/proto/store/revision.protonew file mode 100644index 0000000000..ffd1101655--- /dev/null+++ b/proto/store/revision.proto@@ -0,0 +1,32 @@+syntax = "proto3";++package bytebase.store;++import "google/api/resource.proto";+import "store/release.proto";++option go_package = "generated-go/store";++message RevisionPayload {+ // Format: projects/{project}/releases/{release}+ // Can be empty.+ string release = 1 [(google.api.resource_reference) = {type: "bytebase.com/Release"}];++ // The sheet that holds the content.+ // Format: projects/{project}/sheets/{sheet}+ string sheet = 2 [(google.api.resource_reference) = {type: "bytebase.com/Sheet"}];+ // The SHA1 hash value of the sheet.+ string sheet_sha1 = 3;++ ReleaseFileType type = 4;+ string version = 5;++ // The name of the file in the release.+ // Expressed as a path, e.g. `2.2/V0001_create_table.sql`+ // Can be empty.+ string file = 6;++ // The task run associated with the revision.+ // Can be empty.+ string task_run = 7 [(google.api.resource_reference) = {type: "bytebase.com/TaskRun"}];+}