-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset.sql
68 lines (55 loc) · 2.25 KB
/
reset.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
-- This file is part of the eliona project.
-- Copyright © 2023 LEICOM iTEC AG. All Rights Reserved.
-- ______ _ _
-- | ____| (_)
-- | |__ | |_ ___ _ __ __ _
-- | __| | | |/ _ \| '_ \ / _` |
-- | |____| | | (_) | | | | (_| |
-- |______|_|_|\___/|_| |_|\__,_|
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
-- BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-- NON INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
-- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-- This idempotent script resets the database to a defined state ready for testing.
-- The only thing that remains after testing then are the incremented auto-increment values and app
-- registration (which you can optionally remove as well by uncommenting the last command).
DELETE FROM versioning.patches
WHERE app_name = 'coffeecloud';
INSERT INTO public.eliona_store (app_name, category, version)
VALUES ('coffeecloud', 'app', '1.0.0')
ON CONFLICT (app_name) DO UPDATE SET version = '1.0.0';
INSERT INTO public.eliona_app (app_name, enable)
VALUES ('coffeecloud', 't')
ON CONFLICT (app_name) DO UPDATE SET initialized_at = null;
DROP SCHEMA IF EXISTS coffeecloud CASCADE;
DELETE FROM heap
WHERE asset_id IN (
SELECT asset_id
FROM asset
WHERE asset_type LIKE E'coffeecloud\\_%'
);
DELETE FROM attribute_schema
WHERE asset_type LIKE E'coffeecloud\\_%';
DELETE FROM asset
WHERE asset_type LIKE E'coffeecloud\\_%';
DELETE FROM asset_type
WHERE asset_type LIKE E'coffeecloud\\_%';
DELETE FROM public.widget_data
WHERE widget_id IN (
SELECT public.widget.id
FROM public.widget
JOIN public.dashboard USING (dashboard_id)
WHERE public.dashboard.name LIKE 'CoffeeCloud%'
);
DELETE FROM public.widget
WHERE dashboard_id IN (
SELECT dashboard_id
FROM public.dashboard
WHERE name LIKE 'CoffeeCloud%'
);
DELETE FROM public.dashboard
WHERE name LIKE 'CoffeeCloud%';
-- DELETE FROM eliona_app WHERE app_name = 'coffeecloud';
-- DELETE FROM eliona_store WHERE app_name = 'coffeecloud';