diff --git a/pkg/sql2pgroll/create_table.go b/pkg/sql2pgroll/create_table.go index 01be619d..bfbee236 100644 --- a/pkg/sql2pgroll/create_table.go +++ b/pkg/sql2pgroll/create_table.go @@ -139,9 +139,11 @@ func convertColumnDef(tableName string, col *pgq.ColumnDef) (*migrations.Column, if foreignKey == nil { return nil, nil } - case pgq.ConstrType_CONSTR_ATTR_NOT_DEFERRABLE: - // NOT DEFERRABLE constraints are the default and are supported, but no - // extra annotation is needed + case + pgq.ConstrType_CONSTR_ATTR_NOT_DEFERRABLE, + pgq.ConstrType_CONSTR_ATTR_IMMEDIATE: + // NOT DEFERRABLE and INITIALLY IMMEDIATE constraints are the default and + // are supported, but no extra annotation is needed continue case pgq.ConstrType_CONSTR_GENERATED: // Generated columns are not supported @@ -152,9 +154,6 @@ func convertColumnDef(tableName string, col *pgq.ColumnDef) (*migrations.Column, case pgq.ConstrType_CONSTR_ATTR_DEFERRABLE: // Deferrable constraints are not supported return nil, nil - case pgq.ConstrType_CONSTR_ATTR_IMMEDIATE: - // Initially immediate deferred constraints are not supported - return nil, nil case pgq.ConstrType_CONSTR_ATTR_DEFERRED: // Initially deferred deferred constraints are not supported return nil, nil diff --git a/pkg/sql2pgroll/create_table_test.go b/pkg/sql2pgroll/create_table_test.go index f7235c3c..05963bdc 100644 --- a/pkg/sql2pgroll/create_table_test.go +++ b/pkg/sql2pgroll/create_table_test.go @@ -44,6 +44,10 @@ func TestConvertCreateTableStatements(t *testing.T) { sql: "CREATE TABLE foo(a int UNIQUE NOT DEFERRABLE)", expectedOp: expect.CreateTableOp5, }, + { + sql: "CREATE TABLE foo(a int UNIQUE INITIALLY IMMEDIATE)", + expectedOp: expect.CreateTableOp5, + }, { sql: "CREATE TABLE foo(a int PRIMARY KEY)", expectedOp: expect.CreateTableOp6, @@ -52,6 +56,10 @@ func TestConvertCreateTableStatements(t *testing.T) { sql: "CREATE TABLE foo(a int PRIMARY KEY NOT DEFERRABLE)", expectedOp: expect.CreateTableOp6, }, + { + sql: "CREATE TABLE foo(a int PRIMARY KEY INITIALLY IMMEDIATE)", + expectedOp: expect.CreateTableOp6, + }, { sql: "CREATE TABLE foo(a int CHECK (a > 0))", expectedOp: expect.CreateTableOp10, @@ -64,6 +72,10 @@ func TestConvertCreateTableStatements(t *testing.T) { sql: "CREATE TABLE foo(a int REFERENCES bar(b) NOT DEFERRABLE)", expectedOp: expect.CreateTableOp12, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) INITIALLY IMMEDIATE)", + expectedOp: expect.CreateTableOp12, + }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON UPDATE NO ACTION)", expectedOp: expect.CreateTableOp12,