File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -143,6 +143,8 @@ let onlyIntPrimaryKeyAutoincrement =
143143 " SQ060: AUTOINCREMENT can only be specified for an INT or INT64 column"
144144let tableAlreadyHasPrimaryKey table =
145145 sprintf " SQ061: ``%O `` already has ``%O `` as its primary key constraint" table
146+ let cannotDropLastColumn table columnName =
147+ sprintf " SQ062: ``%O `` can't be dropped because it is the last column remaining in table ``%O ``" columnName table
146148
147149
148150let tableNameNotSuitableForPG =
Original file line number Diff line number Diff line change @@ -303,6 +303,8 @@ let dropColumn tableName (column : Name) =
303303 failAt tableName.Source <| Error.columnIsReferencedByConstraints column [ refName]
304304 | _ -> ()
305305 let table = { table with Columns = table.Columns |> Map.remove column }
306+ if table.Columns |> Map.isEmpty then
307+ failAt tableName.Source <| Error.cannotDropLastColumn tableName.Value column
306308 return ! putObject tableName ( SchemaTable table)
307309 else
308310 failAt tableName.Source <| Error.columnIsReferencedByConstraints column coveredByConstraints
Original file line number Diff line number Diff line change @@ -76,4 +76,11 @@ let ``string can't be autoincrement`` () =
7676 { defaultTest with
7777 Migration = " create table Foo(x string(10) primary key autoincrement)"
7878 Expect = BadMigration <| Error.onlyIntPrimaryKeyAutoincrement
79+ } |> assertSimple
80+
81+ [<Test>]
82+ let ``can 't drop last column`` () =
83+ { defaultTest with
84+ Migration = " create table Foo(x int); alter table Foo drop column x"
85+ Expect = BadMigration <| Error.cannotDropLastColumn " main.Foo" " x"
7986 } |> assertSimple
You can’t perform that action at this time.
0 commit comments