From fe2769b713e9a540c1a2d0a7bcb11d5e64696a91 Mon Sep 17 00:00:00 2001 From: Varun Rajput Date: Sun, 8 Dec 2024 17:42:24 +0530 Subject: [PATCH] Show On Delete constraint in Schema Designer --- ihp-ide/IHP/IDE/SchemaDesigner/View/Layout.hs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ihp-ide/IHP/IDE/SchemaDesigner/View/Layout.hs b/ihp-ide/IHP/IDE/SchemaDesigner/View/Layout.hs index 2105f17cc..3d83cb7c1 100644 --- a/ihp-ide/IHP/IDE/SchemaDesigner/View/Layout.hs +++ b/ihp-ide/IHP/IDE/SchemaDesigner/View/Layout.hs @@ -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|FOREIGN KEY: {referenceTable}|] + Just addConstraint@AddConstraint { constraint = ForeignKeyConstraint { name = Just constraintName, referenceTable, onDelete = onDeleteConstraint } } -> [hsx|FOREIGN KEY: {referenceTable} (On Delete: {onDeleteText})|] + 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 } } ->