diff --git a/plugins/destination/plugin.go b/plugins/destination/plugin.go index 3387339bbd..5c3c0995d4 100644 --- a/plugins/destination/plugin.go +++ b/plugins/destination/plugin.go @@ -186,6 +186,7 @@ func (p *Plugin) Init(ctx context.Context, logger zerolog.Logger, spec specs.Des // we implement all DestinationClient functions so we can hook into pre-post behavior func (p *Plugin) Migrate(ctx context.Context, tables schema.Tables) error { SetDestinationManagedCqColumns(tables) + setCqIDNotNullColumnForTables(tables) return p.client.Migrate(ctx, tables) } @@ -285,7 +286,20 @@ func SetDestinationManagedCqColumns(tables []*schema.Table) { for _, table := range tables { table.OverwriteOrAddColumn(&schema.CqSyncTimeColumn) table.OverwriteOrAddColumn(&schema.CqSourceNameColumn) - SetDestinationManagedCqColumns(table.Relations) } } + +// this is for backward compatibility for sources that didn't update the SDK yet +// TODO: remove this in the future once all sources have updated the SDK +func setCqIDNotNullColumnForTables(tables []*schema.Table) { + for _, table := range tables { + for i, c := range table.Columns { + if c.Name == schema.CqIDColumn.Name { + table.Columns[i].CreationOptions.NotNull = true + return + } + } + setCqIDNotNullColumnForTables(table.Relations) + } +} diff --git a/schema/meta.go b/schema/meta.go index 50a61697c6..0d99ec7724 100644 --- a/schema/meta.go +++ b/schema/meta.go @@ -16,6 +16,9 @@ var CqIDColumn = Column{ Type: TypeUUID, Description: "Internal CQ ID of the row", Resolver: cqUUIDResolver(), + CreationOptions: ColumnCreationOptions{ + NotNull: true, + }, } var CqParentIDColumn = Column{ Name: "_cq_parent_id", diff --git a/schema/type_test.go b/schema/type_test.go index 4fbde7e7b6..712a13d502 100644 --- a/schema/type_test.go +++ b/schema/type_test.go @@ -3,7 +3,6 @@ package schema import ( "encoding/json" "errors" - "fmt" "net" "strings" "testing" @@ -59,7 +58,6 @@ func TestCQTypesMarshal(t *testing.T) { &Bool{Bool: true, Status: Present}, } b, err := json.Marshal(cqTypes) - fmt.Println(string(b)) if err != nil { t.Fatal(err) }