-
Notifications
You must be signed in to change notification settings - Fork 2
/
reset.sql
67 lines (54 loc) · 2.1 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
-- 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).
INSERT INTO public.eliona_store (app_name, category, version)
VALUES ('hailo', 'app', '1.0.0')
ON CONFLICT (app_name) DO UPDATE SET version = '1.0.0';
INSERT INTO public.eliona_app (app_name, enable)
VALUES ('hailo', 't')
ON CONFLICT (app_name) DO UPDATE SET initialized_at = null;
DELETE FROM versioning.patches
WHERE app_name = 'hailo';
DROP SCHEMA IF EXISTS hailo CASCADE;
DELETE FROM public.heap
WHERE asset_id IN (
SELECT asset_id
FROM public.asset
WHERE asset_type LIKE 'Hailo %'
);
DELETE FROM public.attribute_schema
WHERE asset_type LIKE 'Hailo %';
DELETE FROM public.asset
WHERE asset_type LIKE 'Hailo %';
DELETE FROM public.asset_type
WHERE asset_type LIKE 'Hailo %';
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 'Hailo%'
);
DELETE FROM public.widget
WHERE dashboard_id IN (
SELECT dashboard_id
FROM public.dashboard
WHERE name LIKE 'Hailo%'
);
DELETE FROM public.dashboard
WHERE name LIKE 'Hailo%'
-- DELETE FROM eliona_app WHERE app_name = 'template';