-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathai-interaction-cleanup.sql
More file actions
53 lines (42 loc) · 1.6 KB
/
Copy pathai-interaction-cleanup.sql
File metadata and controls
53 lines (42 loc) · 1.6 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
-- =============================================================
-- AI Interaction Metadata Cleanup Script
-- Run this against your PostgreSQL database to remove all
-- metadata and data associated with the aiInteraction model.
-- =============================================================
BEGIN;
-- 1. Remove menu item
DELETE FROM ss_menu_item_metadata
WHERE name = 'aiInteraction-menu-item';
-- 2. Remove action
DELETE FROM ss_action_metadata
WHERE name = 'aiInteraction-list-action';
-- 3. Remove user-level view customisations for aiInteraction views
DELETE FROM ss_user_view_metadata
WHERE view_metadata_id IN (
SELECT id FROM ss_view_metadata
WHERE name IN ('aiInteraction-list-view', 'aiInteraction-form-view')
);
-- 4. Remove saved filters pointing at the aiInteraction model
DELETE FROM ss_saved_fitlers
WHERE model_id = (
SELECT id FROM ss_model_metadata WHERE singular_name = 'aiInteraction'
);
-- 5. Remove security rules scoped to the aiInteraction model
DELETE FROM ss_security_rule
WHERE model_metadata_id = (
SELECT id FROM ss_model_metadata WHERE singular_name = 'aiInteraction'
);
-- 6. Remove views
DELETE FROM ss_view_metadata
WHERE name IN ('aiInteraction-list-view', 'aiInteraction-form-view');
-- 7. Remove field metadata belonging to the aiInteraction model
DELETE FROM ss_field_metadata
WHERE model_id = (
SELECT id FROM ss_model_metadata WHERE singular_name = 'aiInteraction'
);
-- 8. Remove the model metadata record itself
DELETE FROM ss_model_metadata
WHERE singular_name = 'aiInteraction';
-- 9. Drop the actual data table
DROP TABLE IF EXISTS ss_ai_interactions;
COMMIT;