2018-09-28 13:52:54 +03:00
|
|
|
module Hasura.RQL.DDL.Utils
|
|
|
|
( clearHdbViews
|
|
|
|
) where
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-10-19 05:15:28 +03:00
|
|
|
import qualified Database.PG.Query as Q
|
2019-05-03 13:42:26 +03:00
|
|
|
|
|
|
|
import Hasura.Prelude
|
2018-06-27 16:11:32 +03:00
|
|
|
|
2018-09-05 14:26:46 +03:00
|
|
|
clearHdbViews :: Q.Tx ()
|
2020-03-26 23:42:33 +03:00
|
|
|
clearHdbViews = Q.multiQ (Q.fromText clearHdbViewsFunc)
|
2018-09-05 14:26:46 +03:00
|
|
|
|
2019-05-03 13:42:26 +03:00
|
|
|
clearHdbViewsFunc :: Text
|
2018-09-05 14:26:46 +03:00
|
|
|
clearHdbViewsFunc =
|
|
|
|
"DO $$ DECLARE \
|
2019-05-03 13:42:26 +03:00
|
|
|
\ 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 $$; "
|