Skip to content

Commit

Permalink
Show On Delete constraint in Schema Designer
Browse files Browse the repository at this point in the history
  • Loading branch information
rvarun11 committed Dec 8, 2024
1 parent ad90fc2 commit fe2769b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ihp-ide/IHP/IDE/SchemaDesigner/View/Layout.hs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,16 @@ renderColumn Column { name, columnType, defaultValue, notNull, isUnique } id tab
Just value -> [hsx|default: {compileExpression value} |]
Nothing -> mempty
renderForeignKey = case findForeignKey statements tableName name of
Just addConstraint@AddConstraint { constraint = ForeignKeyConstraint { name = Just constraintName, referenceTable } } -> [hsx|<a href={EditForeignKeyAction tableName name constraintName referenceTable} class="d-block nounderline">FOREIGN KEY: {referenceTable}</a>|]
Just addConstraint@AddConstraint { constraint = ForeignKeyConstraint { name = Just constraintName, referenceTable, onDelete = onDeleteConstraint } } -> [hsx|<a href={EditForeignKeyAction tableName name constraintName referenceTable} class="d-block nounderline">FOREIGN KEY: {referenceTable} (On Delete: {onDeleteText})</a>|]
where
onDeleteText :: Text
onDeleteText = case onDeleteConstraint of
Just NoAction -> "No Action"
Just Restrict -> "Restrict"
Just SetNull -> "Set Null"
Just SetDefault -> "Set Default"
Just Cascade -> "Cascade"
Nothing -> "No Action"
_ -> mempty
foreignKeyOption = case findForeignKey statements tableName name of
Just addConstraint@AddConstraint { constraint = ForeignKeyConstraint { name = Just constraintName, referenceTable } } ->
Expand Down

0 comments on commit fe2769b

Please sign in to comment.