Skip to content

Commit

Permalink
Fixed auto generated migration for a new enum value fails because SQL…
Browse files Browse the repository at this point in the history
… compiler branch is not implemented
  • Loading branch information
mpscholten committed Dec 20, 2021
1 parent 9e1f4ae commit 7e808f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions IHP/IDE/SchemaDesigner/Compiler.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Test/IDE/SchemaDesigner/CompilerSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7e808f0

Please sign in to comment.