Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit 2b5c6b5

Browse files
author
alishakawaguchi
authored
NEOS-1791: Add Mysql init schema set and enum test (#3417)
1 parent 252ee88 commit 2b5c6b5

6 files changed

Lines changed: 102 additions & 2 deletions

File tree

internal/integration-tests/worker/workflow/mysql_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,7 @@ func test_mysql_schema_reconciliation(
580580
{schema: schema, table: "cyclic_table", rowCount: 3},
581581
{schema: schema, table: "astronaut", rowCount: 2},
582582
{schema: schema, table: "astronaut_log", rowCount: 2},
583+
{schema: schema, table: "plants", rowCount: 3},
583584
}
584585

585586
for _, expected := range expectedResults {
@@ -767,7 +768,7 @@ func test_mysql_schema_reconciliation_column_values(
767768
testutil_testdata.VerifySQLTableColumnValues(t, ctx, mysql.Source.DB, mysql.Target.DB, schema, "multi_col_parent", sqlmanager_shared.MysqlDriver, []string{"mcp_a", "mcp_b"})
768769
testutil_testdata.VerifySQLTableColumnValues(t, ctx, mysql.Source.DB, mysql.Target.DB, schema, "multi_col_child", sqlmanager_shared.MysqlDriver, []string{"mc_child_id"})
769770
testutil_testdata.VerifySQLTableColumnValues(t, ctx, mysql.Source.DB, mysql.Target.DB, schema, "cyclic_table", sqlmanager_shared.MysqlDriver, []string{"cycle_id"})
770-
771+
testutil_testdata.VerifySQLTableColumnValues(t, ctx, mysql.Source.DB, mysql.Target.DB, schema, "plants", sqlmanager_shared.MysqlDriver, []string{"plant_id"})
771772
}
772773

773774
func cleanupMysqlDatabases(ctx context.Context, mysql *tcmysql.MysqlTestSyncContainer, databases []string) error {

internal/integration-tests/worker/workflow/workflow-integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func Test_Workflow(t *testing.T) {
167167
t.Parallel()
168168
test_mysql_schema_reconciliation(t, ctx, mysql, neosyncApi, dbManagers, accountId, sourceConn, destConn, true)
169169
})
170-
t.Run("no_truncate", func(t *testing.T) {
170+
t.Run("retain_data", func(t *testing.T) {
171171
t.Parallel()
172172
test_mysql_schema_reconciliation(t, ctx, mysql, neosyncApi, dbManagers, accountId, sourceConn, destConn, false)
173173
})

internal/testutil/testdata/mysql/schema-init/alter-job-mappings.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,5 +126,29 @@ func GetAlterSyncJobMappings(schema string) []*mgmtv1alpha1.JobMapping {
126126
},
127127
},
128128
},
129+
{
130+
Schema: schema,
131+
Table: "plants",
132+
Column: "climate",
133+
Transformer: &mgmtv1alpha1.JobMappingTransformer{
134+
Config: &mgmtv1alpha1.TransformerConfig{
135+
Config: &mgmtv1alpha1.TransformerConfig_PassthroughConfig{
136+
PassthroughConfig: &mgmtv1alpha1.Passthrough{},
137+
},
138+
},
139+
},
140+
},
141+
{
142+
Schema: schema,
143+
Table: "plants",
144+
Column: "soil_types",
145+
Transformer: &mgmtv1alpha1.JobMappingTransformer{
146+
Config: &mgmtv1alpha1.TransformerConfig{
147+
Config: &mgmtv1alpha1.TransformerConfig_PassthroughConfig{
148+
PassthroughConfig: &mgmtv1alpha1.Passthrough{},
149+
},
150+
},
151+
},
152+
},
129153
}
130154
}

internal/testutil/testdata/mysql/schema-init/alter-statements.sql

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,10 @@ ALTER TABLE astronaut_log
269269

270270
ALTER TABLE astronaut
271271
MODIFY COLUMN first_name VARCHAR (20) COMMENT 'I\'m an astronaut';
272+
273+
274+
ALTER TABLE plants
275+
ADD COLUMN climate ENUM('Tropical', 'Desert', 'Temperate') NOT NULL DEFAULT 'Temperate';
276+
277+
ALTER TABLE plants
278+
ADD COLUMN soil_types SET('Sandy', 'Clay', 'Loamy', 'Silty', 'Peaty') NOT NULL DEFAULT 'Loamy';

internal/testutil/testdata/mysql/schema-init/create-tables.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,3 +472,19 @@ INSERT INTO astronaut_log (
472472
VALUES
473473
(1, 'Neil Armstrong', 'INSERTED', NOW()),
474474
(2, 'Buzz Aldrin', 'INSERTED', NOW());
475+
476+
477+
CREATE TABLE IF NOT EXISTS plants (
478+
plant_id INT PRIMARY KEY AUTO_INCREMENT,
479+
plant_name VARCHAR(100) NOT NULL,
480+
plant_type ENUM('Alive', 'Dormant', 'Dead') NOT NULL,
481+
water_types SET('Rainwater', 'Tapwater', 'Wellwater') NOT NULL
482+
);
483+
484+
INSERT INTO plants (plant_name, plant_type, water_types)
485+
VALUES
486+
('Palm Tree', 'Alive', 'Rainwater'),
487+
('Cactus', 'Dormant', 'Rainwater'),
488+
('Flower', 'Dead', 'Wellwater');
489+
490+

internal/testutil/testdata/mysql/schema-init/job-mappings.go

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

0 commit comments

Comments
 (0)