From 0da285a96cbea2af33188867f65f33c95cedca10 Mon Sep 17 00:00:00 2001 From: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> Date: Sun, 9 Jun 2024 08:55:03 +0300 Subject: [PATCH] adding more tests Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com> --- go/vt/schemadiff/schema_diff_test.go | 34 ++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/go/vt/schemadiff/schema_diff_test.go b/go/vt/schemadiff/schema_diff_test.go index b1e253b9b27..8adc4fc8d68 100644 --- a/go/vt/schemadiff/schema_diff_test.go +++ b/go/vt/schemadiff/schema_diff_test.go @@ -1116,6 +1116,40 @@ func TestSchemaDiff(t *testing.T) { conflictingDiffs: 2, instantCapability: InstantDDLCapabilityImpossible, }, + { + name: "add and drop FK, add and drop column, impossible order even with create table first strategy", + fromQueries: []string{ + "create table t1 (id int primary key, p int, key p_idx (p));", + "create table t2 (id int primary key, p int, key p_idx (p), foreign key (p) references t1 (p) on delete no action);", + }, + toQueries: []string{ + "create table t1 (id int primary key, q int, key q_idx (q));", + "create table t2 (id int primary key, q int, key q_idx (q), foreign key (q) references t1 (q) on delete no action);", + }, + expectDiffs: 2, + expectDeps: 1, + sequential: true, + conflictingDiffs: 2, + instantCapability: InstantDDLCapabilityImpossible, + fkStrategy: ForeignKeyCheckStrategyCreateTableFirst, + }, + { + name: "add and drop FK, add and drop column, impossible order even with ignore strategy", + fromQueries: []string{ + "create table t1 (id int primary key, p int, key p_idx (p));", + "create table t2 (id int primary key, p int, key p_idx (p), foreign key (p) references t1 (p) on delete no action);", + }, + toQueries: []string{ + "create table t1 (id int primary key, q int, key q_idx (q));", + "create table t2 (id int primary key, q int, key q_idx (q), foreign key (q) references t1 (q) on delete no action);", + }, + expectDiffs: 2, + expectDeps: 1, + sequential: true, + conflictingDiffs: 2, + instantCapability: InstantDDLCapabilityImpossible, + fkStrategy: ForeignKeyCheckStrategyIgnore, + }, { name: "add and drop FK, add and drop respective tables, fk strict", fromQueries: []string{