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
10 changes: 10 additions & 0 deletions internal/diff/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,16 @@ func generateTableSQL(table *ir.Table, targetSchema string) string {
columnParts = append(columnParts, fmt.Sprintf(" %s", builder.String()))
}

// Add LIKE clauses
for _, likeClause := range table.LikeClauses {
likeTableName := util.QualifyEntityNameWithQuotes(likeClause.SourceSchema, likeClause.SourceTable, targetSchema)
likeSQL := fmt.Sprintf("LIKE %s", likeTableName)
if likeClause.Options != "" {
likeSQL += " " + likeClause.Options
}
columnParts = append(columnParts, fmt.Sprintf(" %s", likeSQL))
}

// Add constraints inline in the correct order (PRIMARY KEY, UNIQUE, FOREIGN KEY)
inlineConstraints := getInlineConstraintsForTable(table)
for _, constraint := range inlineConstraints {
Expand Down
8 changes: 8 additions & 0 deletions internal/ir/ir.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ type Schema struct {
mu sync.RWMutex // Protects concurrent access to all maps
}

// LikeClause represents a LIKE clause in CREATE TABLE statement
type LikeClause struct {
SourceSchema string `json:"source_schema"`
SourceTable string `json:"source_table"`
Options string `json:"options"` // e.g., "INCLUDING ALL" or "INCLUDING DEFAULTS EXCLUDING INDEXES"
}

// Table represents a database table
type Table struct {
Schema string `json:"schema"`
Expand All @@ -45,6 +52,7 @@ type Table struct {
IsPartitioned bool `json:"is_partitioned"`
PartitionStrategy string `json:"partition_strategy,omitempty"` // RANGE, LIST, HASH
PartitionKey string `json:"partition_key,omitempty"` // Column(s) used for partitioning
LikeClauses []LikeClause `json:"like_clauses,omitempty"` // LIKE clauses in CREATE TABLE
}

// Column represents a table column
Expand Down
Loading