Skip to content

Commit

Permalink
Fall back to raw SQL for COMPRESSION options
Browse files Browse the repository at this point in the history
Column compression options are not representable by `pgroll` `Column`
definitions.
  • Loading branch information
andrew-farries committed Dec 18, 2024
1 parent 2566338 commit 47b410f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 7 additions & 3 deletions pkg/sql2pgroll/create_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,14 @@ func convertColumnDef(col *pgq.ColumnDef) (*migrations.Column, error) {
// canConvertColumnDef returns true iff `col` can be converted to a pgroll
// `Column` definition.
func canConvertColumnDef(col *pgq.ColumnDef) bool {
switch {
// Column storage options are not supported
if col.GetStorageName() != "" {
case col.GetStorageName() != "":
return false
// Column compression options are not supported
case col.GetCompression() != "":
return false
default:
return true
}

return true
}
5 changes: 4 additions & 1 deletion pkg/sql2pgroll/create_table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ func TestUnconvertableCreateTableStatements(t *testing.T) {
"CREATE TABLE foo(a int, LIKE bar)",
"CREATE TABLE foo(LIKE bar)",

// column `STORAGE` options are not supported
// Column `STORAGE` options are not supported
"CREATE TABLE foo(a int STORAGE PLAIN)",

// Column compression options are not supported
"CREATE TABLE foo(a text COMPRESSION pglz)",
}

for _, sql := range tests {
Expand Down

0 comments on commit 47b410f

Please sign in to comment.