graphql-engine/server/src-lib/Hasura/RQL/DDL/Utils.hs

21 lines
572 B
Haskell
Raw Normal View History

module Hasura.RQL.DDL.Utils
( clearHdbViews
) where
2018-06-27 16:11:32 +03:00
import qualified Database.PG.Query as Q
import Hasura.Prelude
2018-06-27 16:11:32 +03:00
2018-09-05 14:26:46 +03:00
clearHdbViews :: Q.Tx ()
clearHdbViews = Q.multiQ (Q.fromText clearHdbViewsFunc)
2018-09-05 14:26:46 +03:00
clearHdbViewsFunc :: Text
2018-09-05 14:26:46 +03:00
clearHdbViewsFunc =
"DO $$ DECLARE \
\ r RECORD; \
\ BEGIN \
\ FOR r IN (SELECT routine_name FROM information_schema.routines WHERE specific_schema = 'hdb_views' ORDER BY routine_name) LOOP \
\ EXECUTE 'DROP FUNCTION hdb_views.' || quote_ident(r.routine_name) || '() CASCADE'; \
\ END LOOP; \
\ END $$; "