-
Notifications
You must be signed in to change notification settings - Fork 2
/
forest_custodian.go
59 lines (52 loc) · 1.48 KB
/
forest_custodian.go
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
/*-
* Copyright (c) 2016, Jörg Pernfuß <joerg.pernfuss@1und1.de>
* All rights reserved
*
* Use of this source code is governed by a 2-clause BSD license
* that can be found in the LICENSE file.
*/
package stmt
const ForestRebuildDeleteChecks = `
UPDATE soma.checks sc
SET deleted = 'yes'::boolean
WHERE sc.repository_id = $1::uuid;`
const ForestRebuildDeleteInstances = `
UPDATE soma.check_instances sci
SET deleted = 'yes'::boolean
FROM soma.checks sc
WHERE sci.check_id = sc.check_id
AND sc.repository_id = $1::uuid;`
const ForestRepoNameById = `
SELECT repository_name,
organizational_team_id
FROM soma.repositories
WHERE repository_id = $1::uuid;`
const ForestLoadRepository = `
SELECT repository_id,
repository_name,
repository_deleted,
repository_active,
organizational_team_id
FROM soma.repositories;`
const ForestAddRepository = `
INSERT INTO soma.repositories (
repository_id,
repository_name,
repository_active,
repository_deleted,
organizational_team_id,
created_by)
SELECT $1::uuid,
$2::varchar,
$3::boolean,
$4::boolean,
$5::uuid,
user_id
FROM inventory.users iu
WHERE iu.user_uid = $6::varchar
AND NOT EXISTS (
SELECT repository_id
FROM soma.repositories
WHERE repository_id = $1::uuid
OR repository_name = $2::varchar);`
// vim: ts=4 sw=4 sts=4 noet fenc=utf-8 ffs=unix