Skip to content

Commit

Permalink
feat: fix tests and documentation
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <[email protected]>
  • Loading branch information
GuptaManan100 committed Oct 16, 2023
1 parent c850445 commit 09345b7
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions changelog/18.0/18.0.0/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ It is disabled by default.
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.

There are 3 foreign key modes now supported in Vitess -
1. `FK_UNMANAGED` -
1. `unmanaged` -
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.
2. `FK_MANAGED` [EXPERIMENTAL] -
2. `managed` [EXPERIMENTAL] -
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.
This ensures that all the operations are logged in binary logs, unlike MySQL implementation of foreign keys.
This enables seamless integration of VReplication with foreign keys.
For more details on what operations Vitess takes please refer to the [design document for foreign keys](https://github.com/vitessio/vitess/issues/12967).
3. `FK_DISALLOW` -
3. `disallow` -
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`.

#### Upgrade process
Expand Down
6 changes: 3 additions & 3 deletions changelog/18.0/18.0.0/summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ It is disabled by default.
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.

There are 3 foreign key modes now supported in Vitess -
1. `FK_UNMANAGED` -
1. `unmanaged` -
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.
2. `FK_MANAGED` [EXPERIMENTAL] -
2. `managed` [EXPERIMENTAL] -
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.
This ensures that all the operations are logged in binary logs, unlike MySQL implementation of foreign keys.
This enables seamless integration of VReplication with foreign keys.
For more details on what operations Vitess takes please refer to the [design document for foreign keys](https://github.com/vitessio/vitess/issues/12967).
3. `FK_DISALLOW` -
3. `disallow` -
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`.

#### Upgrade process
Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vtgate/foreignkey/sharded_vschema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sharded": true,
"foreignKeyMode": "FK_MANAGED",
"foreignKeyMode": "managed",
"vindexes": {
"xxhash": {
"type": "xxhash"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ func TestMain(m *testing.M) {
Name: keyspaceName,
VSchema: `{
"sharded": false,
"foreignKeyMode": "FK_MANAGED"
"foreignKeyMode": "managed"
}`,
}

Expand Down
2 changes: 1 addition & 1 deletion go/test/endtoend/vtgate/foreignkey/unsharded_vschema.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sharded": false,
"foreignKeyMode": "FK_MANAGED",
"foreignKeyMode": "managed",
"tables": {
"u_t1": {},
"u_t2": {},
Expand Down
4 changes: 2 additions & 2 deletions go/vt/vtgate/planbuilder/testdata/vschemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
},
"sharded_fk_allow": {
"sharded": true,
"foreignKeyMode": "FK_MANAGED",
"foreignKeyMode": "managed",
"vindexes": {
"hash_vin": {
"type": "hash_test"
Expand Down Expand Up @@ -746,7 +746,7 @@
}
},
"unsharded_fk_allow": {
"foreignKeyMode": "FK_MANAGED",
"foreignKeyMode": "managed",
"tables": {
"u_tbl1": {},
"u_tbl2": {},
Expand Down
8 changes: 4 additions & 4 deletions go/vt/vtgate/vindexes/vschema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ func TestVSchemaViews(t *testing.T) {
got := string(out)
want := `
{
"foreignKeyMode":"FK_UNMANAGED",
"foreignKeyMode":"unmanaged",
"tables": {
"t1": {
"name": "t1",
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestVSchemaForeignKeys(t *testing.T) {
require.NoError(t, err)
want := `
{
"foreignKeyMode": "FK_UNMANAGED",
"foreignKeyMode": "unmanaged",
"tables": {
"t1": {
"name": "t1",
Expand Down Expand Up @@ -2725,7 +2725,7 @@ func TestVSchemaJSON(t *testing.T) {
want := `{
"sharded": {
"sharded": true,
"foreignKeyMode": "FK_DISALLOW",
"foreignKeyMode": "disallow",
"tables": {
"t3": {
"name": "n3",
Expand All @@ -2750,7 +2750,7 @@ func TestVSchemaJSON(t *testing.T) {
}
},
"unsharded": {
"foreignKeyMode": "FK_MANAGED",
"foreignKeyMode": "managed",
"tables": {
"t1": {
"name": "n1",
Expand Down
2 changes: 1 addition & 1 deletion go/vt/vttablet/tabletserver/vstreamer/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestUpdateVSchema(t *testing.T) {
"keyspaces": {
"vttest": {
"sharded": true,
"foreignKeyMode": "FK_UNMANAGED",
"foreignKeyMode": "unmanaged",
"tables": {
"t1": {
"name": "t1",
Expand Down

0 comments on commit 09345b7

Please sign in to comment.