Skip to content

Commit 8add2b3

Browse files
authored
feat: Add destination tests for removing a unique constraint (#1558)
#### Summary This adds a test for how destinations will handle removing a unique constraint
1 parent 09c24f1 commit 8add2b3

File tree

2 files changed

+34
-6
lines changed

2 files changed

+34
-6
lines changed

plugin/testing_write.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,13 @@ type WriterTestSuite struct {
3939

4040
// SafeMigrations defines which migrations are supported by the plugin in safe migrate mode
4141
type SafeMigrations struct {
42-
AddColumn bool
43-
AddColumnNotNull bool
44-
RemoveColumn bool
45-
RemoveColumnNotNull bool
46-
ChangeColumn bool
47-
MovePKToCQOnly bool
42+
AddColumn bool
43+
AddColumnNotNull bool
44+
RemoveColumn bool
45+
RemoveColumnNotNull bool
46+
ChangeColumn bool
47+
RemoveUniqueConstraint bool
48+
MovePKToCQOnly bool
4849
}
4950

5051
type WriterTestSuiteTests struct {

plugin/testing_write_migrate.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,33 @@ func (s *WriterTestSuite) testMigrate(
249249
}
250250
})
251251

252+
t.Run("remove_unique_constraint_only"+suffix, func(t *testing.T) {
253+
if !forceMigrate && !s.tests.SafeMigrations.RemoveUniqueConstraint {
254+
t.Skip("skipping test: remove_unique_constraint_only")
255+
}
256+
tableName := "remove_unique_constraint_only" + suffix + "_" + tableUUIDSuffix()
257+
source := &schema.Table{
258+
Name: tableName,
259+
Columns: schema.ColumnList{
260+
{Name: "_cq_id", Type: types.ExtensionTypes.UUID, Unique: true},
261+
{Name: "id", Type: arrow.PrimitiveTypes.Int64},
262+
{Name: "uuid", Type: types.ExtensionTypes.UUID},
263+
{Name: "bool", Type: arrow.FixedWidthTypes.Boolean, NotNull: true},
264+
}}
265+
target := &schema.Table{
266+
Name: tableName,
267+
Columns: schema.ColumnList{
268+
{Name: "_cq_id", Type: types.ExtensionTypes.UUID},
269+
{Name: "id", Type: arrow.PrimitiveTypes.Int64},
270+
{Name: "uuid", Type: types.ExtensionTypes.UUID},
271+
{Name: "bool", Type: arrow.FixedWidthTypes.Boolean, NotNull: true},
272+
}}
273+
require.NoError(t, s.migrate(ctx, target, source, s.tests.SafeMigrations.RemoveUniqueConstraint, forceMigrate))
274+
if !forceMigrate {
275+
require.NoError(t, s.migrate(ctx, target, target, true, false))
276+
}
277+
})
278+
252279
t.Run("move_to_cq_id_only"+suffix, func(t *testing.T) {
253280
if !forceMigrate && !s.tests.SafeMigrations.MovePKToCQOnly {
254281
t.Skip("skipping test: move_to_cq_id_only")

0 commit comments

Comments
 (0)