From f98a73b355c3005da746e2d65c8e9bb1613be3ec Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 23 Oct 2024 12:16:51 +0530 Subject: [PATCH] feat: remove sql changes from schemacopy Signed-off-by: Manan Gupta --- go/vt/schemadiff/schema_diff_test.go | 12 ++++++++++++ .../schema/schematracker/schemacopy.sql | 18 +++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/go/vt/schemadiff/schema_diff_test.go b/go/vt/schemadiff/schema_diff_test.go index f6477c1885f..e78ddd2a1bd 100644 --- a/go/vt/schemadiff/schema_diff_test.go +++ b/go/vt/schemadiff/schema_diff_test.go @@ -454,6 +454,18 @@ func TestSchemaDiff(t *testing.T) { expectDeps: 1, conflictingDiffs: 2, }, + { + name: "two identical tables, one with explicit charset, one without", + fromQueries: []string{ + "create table t1 (id int primary key, foo varchar(64) character set utf8mb3 collate utf8mb3_bin)", + }, + toQueries: []string{ + "create table t1 (id int primary key, foo varchar(64) collate utf8mb3_bin)", + }, + // This isn't strictly correct. We have a diff even though there shouldn't be one. + expectDiffs: 1, + entityOrder: []string{"t1"}, + }, // FKs { diff --git a/go/vt/sidecardb/schema/schematracker/schemacopy.sql b/go/vt/sidecardb/schema/schematracker/schemacopy.sql index 3abb922f81f..296bb34df14 100644 --- a/go/vt/sidecardb/schema/schematracker/schemacopy.sql +++ b/go/vt/sidecardb/schema/schematracker/schemacopy.sql @@ -16,13 +16,13 @@ limitations under the License. CREATE TABLE IF NOT EXISTS schemacopy ( - `table_schema` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL, - `table_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL, - `column_name` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, - `ordinal_position` bigint unsigned NOT NULL, - `character_set_name` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `collation_name` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL, - `data_type` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL, - `column_key` varchar(3) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL, + `table_schema` varchar(64) NOT NULL, + `table_name` varchar(64) NOT NULL, + `column_name` varchar(64) NOT NULL, + `ordinal_position` bigint unsigned NOT NULL, + `character_set_name` varchar(32) DEFAULT NULL, + `collation_name` varchar(32) DEFAULT NULL, + `data_type` varchar(64) NOT NULL, + `column_key` varchar(3) NOT NULL, PRIMARY KEY (`table_schema`, `table_name`, `ordinal_position`) -) ENGINE = InnoDB, CHARACTER SET = utf8mb3 +) ENGINE = InnoDB