server: check for event triggers before throwing source-cleanup-failed warnings

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8885
GitOrigin-RevId: 7e02829608c6838f5db8226b532b436dd97f1b22
This commit is contained in:
paritosh-08 2023-04-25 01:20:48 +05:30 committed by hasura-bot
parent 8af30c4c6b
commit b158aae73b
2 changed files with 22 additions and 29 deletions

View File

@ -119,14 +119,6 @@ tests = do
`shouldReturnYaml` [yaml|
is_consistent: true
inconsistent_objects: []
warnings:
- code: source-cleanup-failed
message: >-
Could not cleanup the source '"postgres"' while dropping it from the graphql-engine as it is
inconsistent. Please consider cleaning the resources created by the graphql engine, refer
https://hasura.io/docs/latest/graphql/core/event-triggers/remove-event-triggers/#clean-footprints-manually
type: source
name: source postgres
|]
reloadMetadata :: Value

View File

@ -103,10 +103,11 @@ postDropSourceHookHelper ::
postDropSourceHookHelper oldSchemaCache sourceName sourceMetadataBackend = do
logger :: (HL.Logger HL.Hasura) <- asks getter
AB.dispatchAnyBackend @BackendMetadata sourceMetadataBackend \(_ :: SourceMetadata b) -> do
AB.dispatchAnyBackend @BackendMetadata sourceMetadataBackend \(oldSourceMetadata :: SourceMetadata b) -> do
let sourceInfoMaybe = unsafeSourceInfo @b =<< HM.lookup sourceName (scSources oldSchemaCache)
case sourceInfoMaybe of
Nothing -> do
unless (null (getTriggersMap oldSourceMetadata)) do
let message =
"Could not cleanup the source '"
<> sourceName
@ -475,8 +476,8 @@ runReplaceMetadataV2' ReplaceMetadataV2 {..} = do
flip catchError catcher do
sourceConfigMaybe <- askSourceConfigMaybe @b source
case sourceConfigMaybe of
Nothing -> do
-- TODO: Add user facing docs on how to drop triggers manually. Issue #7104
Nothing ->
unless (null oldTriggersMap) do
let message =
"Could not drop SQL triggers present in the source '"
<> source