forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvschema.proto
193 lines (167 loc) · 5.75 KB
/
vschema.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
/*
Copyright 2019 The Vitess Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// This file contains the types needed to define a vschema.
syntax = "proto3";
option go_package = "vitess.io/vitess/go/vt/proto/vschema";
package vschema;
import "query.proto";
// RoutingRules specify the high level routing rules for the VSchema.
message RoutingRules {
// rules should ideally be a map. However protos dont't allow
// repeated fields as elements of a map. So, we use a list
// instead.
repeated RoutingRule rules = 1;
}
// RoutingRule specifies a routing rule.
message RoutingRule {
string from_table = 1;
repeated string to_tables = 2;
}
// Keyspace is the vschema for a keyspace.
message Keyspace {
// If sharded is false, vindexes and tables are ignored.
bool sharded = 1;
map<string, Vindex> vindexes = 2;
map<string, Table> tables = 3;
// If require_explicit_routing is true, vindexes and tables are not added to global routing
bool require_explicit_routing = 4;
// foreign_key_mode dictates how Vitess should handle foreign keys for this keyspace.
ForeignKeyMode foreign_key_mode = 5;
enum ForeignKeyMode {
unspecified = 0;
disallow = 1;
unmanaged = 2;
managed = 3;
}
// multi_tenant_mode specifies that the keyspace is multi-tenant. Currently used during migrations with MoveTables.
MultiTenantSpec multi_tenant_spec = 6;
}
message MultiTenantSpec {
// tenant_column is the name of the column that specifies the tenant id.
string tenant_id_column_name = 1;
// tenant_column_type is the type of the column that specifies the tenant id.
query.Type tenant_id_column_type = 2;
}
// Vindex is the vindex info for a Keyspace.
message Vindex {
// The type must match one of the predefined
// (or plugged in) vindex names.
string type = 1;
// params is a map of attribute value pairs
// that must be defined as required by the
// vindex constructors. The values can only
// be strings.
map<string, string> params = 2;
// A lookup vindex can have an owner table defined.
// If so, rows in the lookup table are created or
// deleted in sync with corresponding rows in the
// owner table.
string owner = 3;
}
// Table is the table info for a Keyspace.
message Table {
// If the table is a sequence, type must be
// "sequence".
//
// If the table is a reference, type must be
// "reference".
// See https://vitess.io/docs/reference/features/vschema/#reference-tables.
//
// Otherwise, it should be empty.
string type = 1;
// column_vindexes associates columns to vindexes.
repeated ColumnVindex column_vindexes = 2;
// auto_increment is specified if a column needs
// to be associated with a sequence.
AutoIncrement auto_increment = 3;
// columns lists the columns for the table.
repeated Column columns = 4;
// pinned pins an unsharded table to a specific
// shard, as dictated by the keyspace id.
// The keyspace id is represented in hex form
// like in keyranges.
string pinned = 5;
// column_list_authoritative is set to true if columns is
// an authoritative list for the table. This allows
// us to expand 'select *' expressions.
bool column_list_authoritative = 6;
// reference tables may optionally indicate their source table.
string source = 7;
}
// ColumnVindex is used to associate a column to a vindex.
message ColumnVindex {
// Legacy implementation, moving forward all vindexes should define a list of columns.
string column = 1;
// The name must match a vindex defined in Keyspace.
string name = 2;
// List of columns that define this Vindex
repeated string columns = 3;
}
// Autoincrement is used to designate a column as auto-inc.
message AutoIncrement {
string column = 1;
// The sequence must match a table of type SEQUENCE.
string sequence = 2;
}
// Column describes a column.
message Column {
string name = 1;
query.Type type = 2;
bool invisible = 3;
string default = 4;
string collation_name = 5;
int32 size = 6;
int32 scale = 7;
optional bool nullable = 8;
// values contains the list of values for an enum or set column.
repeated string values = 9;
}
// SrvVSchema is the roll-up of all the Keyspace schema for a cell.
message SrvVSchema {
// keyspaces is a map of keyspace name -> Keyspace object.
map<string, Keyspace> keyspaces = 1;
RoutingRules routing_rules = 2; // table routing rules
ShardRoutingRules shard_routing_rules = 3;
KeyspaceRoutingRules keyspace_routing_rules = 4;
MirrorRules mirror_rules = 5; // mirror rules
}
// ShardRoutingRules specify the shard routing rules for the VSchema.
message ShardRoutingRules {
repeated ShardRoutingRule rules = 1;
}
// ShardRoutingRule specifies a routing rule.
message ShardRoutingRule {
string from_keyspace = 1;
string to_keyspace = 2;
string shard = 3;
}
message KeyspaceRoutingRules {
repeated KeyspaceRoutingRule rules = 1;
}
message KeyspaceRoutingRule {
string from_keyspace = 1;
string to_keyspace = 2;
}
// MirrorRules specify the high level mirror rules for the VSchema.
message MirrorRules {
// rules should ideally be a map. However protos dont't allow
// repeated fields as elements of a map. So, we use a list
// instead.
repeated MirrorRule rules = 1;
}
// MirrorRule specifies a mirror rule.
message MirrorRule {
string from_table = 1;
string to_table = 2;
float percent = 3;
}