Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion plugins/destination/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
3 changes: 3 additions & 0 deletions schema/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 0 additions & 2 deletions schema/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package schema
import (
"encoding/json"
"errors"
"fmt"
"net"
"strings"
"testing"
Expand Down Expand Up @@ -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)
}
Expand Down