Skip to content

Commit

Permalink
Fall back to raw SQL for indexes created with ONLY
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-farries committed Dec 20, 2024
1 parent b807bec commit edd1cd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions pkg/sql2pgroll/create_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ func canConvertCreateIndexStmt(stmt *pgq.IndexStmt) bool {
if stmt.GetIndexIncludingParams() != nil {
return false
}
// Indexes created with ONLY are not supported
if !stmt.GetRelation().GetInh() {
return false
}

for _, param := range stmt.GetIndexParams() {
if param.GetIndexElem().GetCollation() != nil {
return false
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql2pgroll/create_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func TestUnconvertableCreateIndexStatements(t *testing.T) {
// opclasses with or without options are not supported
"CREATE INDEX idx_name ON foo (bar opclass (test = test))",
"CREATE INDEX idx_name ON foo (bar opclass)",
// TODO: Can't figure out how to detect this case
//"CREATE INDEX idx_name ON ONLY foo (bar)",
// Indexes created with ONLY are not supported
"CREATE INDEX idx_name ON ONLY foo (bar)",
}

for _, sql := range tests {
Expand Down

0 comments on commit edd1cd9

Please sign in to comment.