diff --git a/pkg/sql2pgroll/create_table_test.go b/pkg/sql2pgroll/create_table_test.go index 5841e107..032a3c37 100644 --- a/pkg/sql2pgroll/create_table_test.go +++ b/pkg/sql2pgroll/create_table_test.go @@ -36,10 +36,18 @@ func TestConvertCreateTableStatements(t *testing.T) { sql: "CREATE TABLE foo(a int UNIQUE)", expectedOp: expect.CreateTableOp5, }, + { + sql: "CREATE TABLE foo(a int UNIQUE NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp5, + }, { sql: "CREATE TABLE foo(a int PRIMARY KEY)", expectedOp: expect.CreateTableOp6, }, + { + sql: "CREATE TABLE foo(a int PRIMARY KEY NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp6, + }, { sql: "CREATE TABLE foo(a int CHECK (a > 0))", expectedOp: expect.CreateTableOp10, @@ -49,33 +57,57 @@ func TestConvertCreateTableStatements(t *testing.T) { expectedOp: expect.CreateTableOp11, }, { - sql: "CREATE TABLE foo(a int REFERENCES bar(b))", + sql: "CREATE TABLE foo(a int REFERENCES bar(b) NOT DEFERRABLE)", expectedOp: expect.CreateTableOp12, }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON UPDATE NO ACTION)", expectedOp: expect.CreateTableOp12, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON UPDATE NO ACTION NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp12, + }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE NO ACTION)", expectedOp: expect.CreateTableOp12, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE NO ACTION NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp12, + }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE RESTRICT)", expectedOp: expect.CreateTableOp13, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE RESTRICT NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp13, + }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE SET NULL)", expectedOp: expect.CreateTableOp14, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE SET NULL NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp14, + }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE SET DEFAULT)", expectedOp: expect.CreateTableOp15, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE SET DEFAULT NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp15, + }, { sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE CASCADE)", expectedOp: expect.CreateTableOp16, }, + { + sql: "CREATE TABLE foo(a int REFERENCES bar(b) ON DELETE CASCADE NOT DEFERRABLE)", + expectedOp: expect.CreateTableOp16, + }, { sql: "CREATE TABLE foo(a varchar(255))", expectedOp: expect.CreateTableOp3,