Skip to content

Commit a5e819d

Browse files
Rename Foreign Key enum values in VSchema and drop FK_ prefix (#14274)
Signed-off-by: Manan Gupta <[email protected]>
1 parent e7aaa5b commit a5e819d

File tree

22 files changed

+199
-199
lines changed

22 files changed

+199
-199
lines changed

changelog/18.0/18.0.0/release_notes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ It is disabled by default.
8585
A new field `foreignKeyMode` has been added to the VSchema. This field can be provided for each keyspace. The VTGate flag `--foreign_key_mode` has been deprecated in favour of this field.
8686

8787
There are 3 foreign key modes now supported in Vitess -
88-
1. `FK_UNMANAGED` -
88+
1. `unmanaged` -
8989
This mode represents the default behaviour in Vitess, where it does not manage foreign keys column references. Users are responsible for configuring foreign keys in MySQL in such a way that related rows, as determined by foreign keys, reside within the same shard.
90-
2. `FK_MANAGED` [EXPERIMENTAL] -
90+
2. `managed` [EXPERIMENTAL] -
9191
In this experimental mode, Vitess is fully aware of foreign key relationships and actively tracks foreign key constraints using the schema tracker. Vitess takes charge of handling DML operations with foreign keys cascading updates, deletes and verifying restrict. It will also validate parent row existence.
9292
This ensures that all the operations are logged in binary logs, unlike MySQL implementation of foreign keys.
9393
This enables seamless integration of VReplication with foreign keys.
9494
For more details on what operations Vitess takes please refer to the [design document for foreign keys](https://github.com/vitessio/vitess/issues/12967).
95-
3. `FK_DISALLOW` -
95+
3. `disallow` -
9696
In this mode Vitess explicitly disallows any DDL statements that try to create a foreign key constraint. This mode is equivalent to running VTGate with the flag `--foreign_key_mode=disallow`.
9797

9898
#### Upgrade process

changelog/18.0/18.0.0/summary.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ It is disabled by default.
8585
A new field `foreignKeyMode` has been added to the VSchema. This field can be provided for each keyspace. The VTGate flag `--foreign_key_mode` has been deprecated in favour of this field.
8686

8787
There are 3 foreign key modes now supported in Vitess -
88-
1. `FK_UNMANAGED` -
88+
1. `unmanaged` -
8989
This mode represents the default behaviour in Vitess, where it does not manage foreign keys column references. Users are responsible for configuring foreign keys in MySQL in such a way that related rows, as determined by foreign keys, reside within the same shard.
90-
2. `FK_MANAGED` [EXPERIMENTAL] -
90+
2. `managed` [EXPERIMENTAL] -
9191
In this experimental mode, Vitess is fully aware of foreign key relationships and actively tracks foreign key constraints using the schema tracker. Vitess takes charge of handling DML operations with foreign keys cascading updates, deletes and verifying restrict. It will also validate parent row existence.
9292
This ensures that all the operations are logged in binary logs, unlike MySQL implementation of foreign keys.
9393
This enables seamless integration of VReplication with foreign keys.
9494
For more details on what operations Vitess takes please refer to the [design document for foreign keys](https://github.com/vitessio/vitess/issues/12967).
95-
3. `FK_DISALLOW` -
95+
3. `disallow` -
9696
In this mode Vitess explicitly disallows any DDL statements that try to create a foreign key constraint. This mode is equivalent to running VTGate with the flag `--foreign_key_mode=disallow`.
9797

9898
#### Upgrade process

go/test/endtoend/vtgate/foreignkey/sharded_vschema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sharded": true,
3-
"foreignKeyMode": "FK_MANAGED",
3+
"foreignKeyMode": "managed",
44
"vindexes": {
55
"xxhash": {
66
"type": "xxhash"

go/test/endtoend/vtgate/foreignkey/stress/fk_stress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ func TestMain(m *testing.M) {
323323
Name: keyspaceName,
324324
VSchema: `{
325325
"sharded": false,
326-
"foreignKeyMode": "FK_MANAGED"
326+
"foreignKeyMode": "managed"
327327
}`,
328328
}
329329

go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sharded": false,
3-
"foreignKeyMode": "FK_MANAGED",
3+
"foreignKeyMode": "managed",
44
"tables": {
55
"u_t1": {},
66
"u_t2": {},

go/test/vschemawrapper/vschema_wrapper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ func (vw *VSchemaWrapper) PlannerWarning(_ string) {
129129
}
130130

131131
func (vw *VSchemaWrapper) ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error) {
132-
defaultFkMode := vschemapb.Keyspace_FK_UNMANAGED
133-
if vw.V.Keyspaces[keyspace] != nil && vw.V.Keyspaces[keyspace].ForeignKeyMode != vschemapb.Keyspace_FK_DEFAULT {
132+
defaultFkMode := vschemapb.Keyspace_unmanaged
133+
if vw.V.Keyspaces[keyspace] != nil && vw.V.Keyspaces[keyspace].ForeignKeyMode != vschemapb.Keyspace_unspecified {
134134
return vw.V.Keyspaces[keyspace].ForeignKeyMode, nil
135135
}
136136
return defaultFkMode, nil

go/vt/proto/vschema/vschema.pb.go

Lines changed: 96 additions & 96 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

go/vt/schemadiff/semantics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (si *declarativeSchemaInformation) ConnCollation() collations.ID {
5757
}
5858

5959
func (si *declarativeSchemaInformation) ForeignKeyMode(keyspace string) (vschemapb.Keyspace_ForeignKeyMode, error) {
60-
return vschemapb.Keyspace_FK_UNMANAGED, nil
60+
return vschemapb.Keyspace_unmanaged, nil
6161
}
6262

6363
// addTable adds a fake table with an empty column list

go/vt/vtgate/planbuilder/ddl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func checkFKError(vschema plancontext.VSchema, ddlStatement sqlparser.DDLStateme
155155
if err != nil {
156156
return err
157157
}
158-
if fkMode == vschemapb.Keyspace_FK_DISALLOW {
158+
if fkMode == vschemapb.Keyspace_disallow {
159159
fk := &fkContraint{}
160160
_ = sqlparser.Walk(fk.FkWalk, ddlStatement)
161161
if fk.found {

go/vt/vtgate/planbuilder/operators/insert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func createOperatorFromInsert(ctx *plancontext.PlanningContext, ins *sqlparser.I
126126
if err != nil {
127127
return nil, err
128128
}
129-
if ksMode != vschemapb.Keyspace_FK_MANAGED {
129+
if ksMode != vschemapb.Keyspace_managed {
130130
return insOp, nil
131131
}
132132

0 commit comments

Comments
 (0)