-
Notifications
You must be signed in to change notification settings - Fork 28
/
index.go
52 lines (45 loc) · 1.33 KB
/
index.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
// SPDX-License-Identifier: Apache-2.0
package secret
import "context"
const (
// CreateTypeOrgRepo represents a query to create an
// index on the secrets table for the type, org and repo columns.
CreateTypeOrgRepo = `
CREATE INDEX
IF NOT EXISTS
secrets_type_org_repo
ON secrets (type, org, repo);
`
// CreateTypeOrgTeam represents a query to create an
// index on the secrets table for the type, org and team columns.
CreateTypeOrgTeam = `
CREATE INDEX
IF NOT EXISTS
secrets_type_org_team
ON secrets (type, org, team);
`
// CreateTypeOrg represents a query to create an
// index on the secrets table for the type, and org columns.
CreateTypeOrg = `
CREATE INDEX
IF NOT EXISTS
secrets_type_org
ON secrets (type, org);
`
)
// CreateSecretIndexes creates the indexes for the secrets table in the database.
func (e *engine) CreateSecretIndexes(ctx context.Context) error {
e.logger.Tracef("creating indexes for secrets table in the database")
// create the type, org and repo columns index for the secrets table
err := e.client.Exec(CreateTypeOrgRepo).Error
if err != nil {
return err
}
// create the type, org and team columns index for the secrets table
err = e.client.Exec(CreateTypeOrgTeam).Error
if err != nil {
return err
}
// create the type and org columns index for the secrets table
return e.client.Exec(CreateTypeOrg).Error
}