From ecb74332159d1d5e2ea983eed818da9cca8fbca1 Mon Sep 17 00:00:00 2001 From: Andrew Farries Date: Wed, 18 Dec 2024 09:49:37 +0000 Subject: [PATCH] Fall back to raw SQL for `COLLATE` options Column collation options are not representable by `pgroll` `Column` definitions. --- pkg/sql2pgroll/create_table.go | 5 ++++- pkg/sql2pgroll/create_table_test.go | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/sql2pgroll/create_table.go b/pkg/sql2pgroll/create_table.go index 53cdbe16..2eac0a88 100644 --- a/pkg/sql2pgroll/create_table.go +++ b/pkg/sql2pgroll/create_table.go @@ -126,9 +126,12 @@ func canConvertColumnDef(col *pgq.ColumnDef) bool { // Column storage options are not supported case col.GetStorageName() != "": return false - // Column compression options are not supported + // Column compression options are not supported case col.GetCompression() != "": return false + // Column collation options are not supported + case col.GetCollClause() != nil: + return false default: return true } diff --git a/pkg/sql2pgroll/create_table_test.go b/pkg/sql2pgroll/create_table_test.go index d98209f1..325a786a 100644 --- a/pkg/sql2pgroll/create_table_test.go +++ b/pkg/sql2pgroll/create_table_test.go @@ -118,6 +118,9 @@ func TestUnconvertableCreateTableStatements(t *testing.T) { // Column compression options are not supported "CREATE TABLE foo(a text COMPRESSION pglz)", + + // Column collation is not supported + "CREATE TABLE foo(a text COLLATE en_US)", } for _, sql := range tests {