diff --git a/IHP/IDE/SchemaDesigner/Compiler.hs b/IHP/IDE/SchemaDesigner/Compiler.hs index 8772ca284..e5463818d 100644 --- a/IHP/IDE/SchemaDesigner/Compiler.hs +++ b/IHP/IDE/SchemaDesigner/Compiler.hs @@ -46,6 +46,7 @@ compileStatement RenameTable { from, to } = "ALTER TABLE " <> compileIdentifier compileStatement DropPolicy { tableName, policyName } = "DROP POLICY " <> compileIdentifier policyName <> " ON " <> compileIdentifier tableName <> ";" compileStatement SetDefaultValue { tableName, columnName, value } = "ALTER TABLE " <> compileIdentifier tableName <> " ALTER COLUMN " <> compileIdentifier columnName <> " SET DEFAULT " <> compileExpression value <> ";" compileStatement DropDefaultValue { tableName, columnName } = "ALTER TABLE " <> compileIdentifier tableName <> " ALTER COLUMN " <> compileIdentifier columnName <> " DROP DEFAULT;" +compileStatement AddValueToEnumType { enumName, newValue } = "ALTER TYPE " <> compileIdentifier enumName <> " ADD VALUE " <> compileExpression (TextExpression newValue) <> ";" compileStatement UnknownStatement { raw } = raw <> ";" -- | Emit a PRIMARY KEY constraint when there are multiple primary key columns diff --git a/Test/IDE/SchemaDesigner/CompilerSpec.hs b/Test/IDE/SchemaDesigner/CompilerSpec.hs index f5f590510..7f92e1b0b 100644 --- a/Test/IDE/SchemaDesigner/CompilerSpec.hs +++ b/Test/IDE/SchemaDesigner/CompilerSpec.hs @@ -604,3 +604,8 @@ tests = do } ] compileSql statements `shouldBe` sql + + it "should compile 'ALTER TYPE .. ADD VALUE ..;' statements" do + let sql = "ALTER TYPE colors ADD VALUE 'blue';\n" + let statements = [ AddValueToEnumType { enumName = "colors", newValue = "blue" } ] + compileSql statements `shouldBe` sql