Skip to content

Commit 3d3479b

Browse files
authored
feat: Enable destinations to completely skip migration that are not supported (#1560)
Some destinations don't support all migrations types. This allows them to opt out
1 parent 6444604 commit 3d3479b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

plugin/testing_write.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ type SafeMigrations struct {
4848
MovePKToCQOnly bool
4949
}
5050

51+
// Migrations defines which migrations should be skipped completely
52+
type Migrations struct {
53+
RemoveUniqueConstraint bool
54+
MovePKToCQOnly bool
55+
}
56+
5157
type WriterTestSuiteTests struct {
5258
// SkipUpsert skips testing with message.Insert and Upsert=true.
5359
// Usually when a destination is not supporting primary keys
@@ -68,6 +74,8 @@ type WriterTestSuiteTests struct {
6874
// SafeMigrations defines which tests should work with force migration
6975
// and which should pass with safe migration
7076
SafeMigrations SafeMigrations
77+
78+
SkipSpecificMigrations Migrations
7179
}
7280

7381
type NewPluginFunc func() *Plugin

plugin/testing_write_migrate.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ func (s *WriterTestSuite) testMigrate(
250250
})
251251

252252
t.Run("remove_unique_constraint_only"+suffix, func(t *testing.T) {
253+
if s.tests.SkipSpecificMigrations.RemoveUniqueConstraint {
254+
t.Skip("skipping test completely: remove_unique_constraint_only")
255+
}
253256
if !forceMigrate && !s.tests.SafeMigrations.RemoveUniqueConstraint {
254257
t.Skip("skipping test: remove_unique_constraint_only")
255258
}
@@ -277,6 +280,9 @@ func (s *WriterTestSuite) testMigrate(
277280
})
278281

279282
t.Run("move_to_cq_id_only"+suffix, func(t *testing.T) {
283+
if s.tests.SkipSpecificMigrations.MovePKToCQOnly {
284+
t.Skip("skipping test completely: move_to_cq_id_only")
285+
}
280286
if !forceMigrate && !s.tests.SafeMigrations.MovePKToCQOnly {
281287
t.Skip("skipping test: move_to_cq_id_only")
282288
}
@@ -303,8 +309,11 @@ func (s *WriterTestSuite) testMigrate(
303309
}
304310
})
305311
t.Run("move_to_cq_id_only_adding_pkc"+suffix, func(t *testing.T) {
312+
if s.tests.SkipSpecificMigrations.MovePKToCQOnly {
313+
t.Skip("skipping test completely: move_to_cq_id_only_adding_pkc")
314+
}
306315
if !forceMigrate && !s.tests.SafeMigrations.MovePKToCQOnly {
307-
t.Skip("skipping test: move_to_cq_id_only_adding_pk")
316+
t.Skip("skipping test: move_to_cq_id_only_adding_pkc")
308317
}
309318
tableName := "cq_move_to_cq_id_only_adding_pkc" + suffix + "_" + tableUUIDSuffix()
310319
source := &schema.Table{

0 commit comments

Comments
 (0)