-
-
Notifications
You must be signed in to change notification settings - Fork 561
/
Copy pathcleanup.sql
31 lines (28 loc) · 1.09 KB
/
cleanup.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
-- Switch to ACCOUNTADMIN role for full cleanup permissions
USE ROLE ACCOUNTADMIN;
-- Try to use database if it exists
BEGIN
USE DATABASE MSSQL_API_DB;
USE SCHEMA MSSQL_API_SCHEMA;
-- Drop objects that need database context first
DROP PROCEDURE IF EXISTS OCKAM_MSSQL_QUERY();
DROP PROCEDURE IF EXISTS OCKAM_MSSQL_EXECUTE();
DROP FUNCTION IF EXISTS _OCKAM_QUERY_MSSQL(STRING);
DROP FUNCTION IF EXISTS _OCKAM_MSSQL_EXECUTE(STRING);
DROP FUNCTION IF EXISTS OCKAM_MSSQL_INSERT(STRING, ARRAY);
DROP IMAGE REPOSITORY IF EXISTS MSSQL_API_REPOSITORY;
DROP SCHEMA IF EXISTS MSSQL_API_SCHEMA;
EXCEPTION
WHEN OTHER THEN
-- Database doesn't exist, continue with other cleanup
END;
-- Drop objects that don't need database context
DROP SERVICE IF EXISTS MSSQL_API_CLIENT;
DROP INTEGRATION IF EXISTS OCKAM;
DROP INTEGRATION IF EXISTS OCSP;
DROP NETWORK RULE IF EXISTS OCKAM_OUT;
DROP NETWORK RULE IF EXISTS OCSP_OUT;
DROP COMPUTE POOL IF EXISTS MSSQL_API_CP;
DROP WAREHOUSE IF EXISTS MSSQL_API_WH;
DROP DATABASE IF EXISTS MSSQL_API_DB;
DROP ROLE IF EXISTS MSSQL_API_ROLE;