Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: integration keys sqlc #3293

Merged
merged 5 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions app/initstores.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,7 @@ func (app *App) initStores(ctx context.Context) error {
}

if app.IntegrationKeyStore == nil {
app.IntegrationKeyStore, err = integrationkey.NewStore(ctx, app.db)
}
if err != nil {
return errors.Wrap(err, "init integration key store")
app.IntegrationKeyStore = integrationkey.NewStore(ctx, app.db)
}

if app.ScheduleRuleStore == nil {
Expand Down
2 changes: 1 addition & 1 deletion devtools/pgdump-lite/pgd/db.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion devtools/pgdump-lite/pgd/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion devtools/pgdump-lite/pgd/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

132 changes: 132 additions & 0 deletions gadb/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion graphql2/graphqlapp/integrationkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (m *Mutation) CreateIntegrationKey(ctx context.Context, input graphql2.Crea
Name: input.Name,
Type: integrationkey.Type(input.Type),
}
key, err = m.IntKeyStore.CreateKeyTx(ctx, tx, key)
key, err = m.IntKeyStore.Create(ctx, tx, key)
return err
})
return key, err
Expand Down
2 changes: 1 addition & 1 deletion graphql2/graphqlapp/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (a *Mutation) tryDeleteAll(ctx context.Context, input []assignment.RawTarge
case assignment.TargetTypeEscalationPolicy:
err = errors.Wrap(a.PolicyStore.DeleteManyPoliciesTx(ctx, tx, ids), "delete escalation policies")
case assignment.TargetTypeIntegrationKey:
err = errors.Wrap(a.IntKeyStore.DeleteManyTx(ctx, tx, ids), "delete integration keys")
err = errors.Wrap(a.IntKeyStore.DeleteMany(ctx, tx, ids), "delete integration keys")
case assignment.TargetTypeSchedule:
err = errors.Wrap(a.ScheduleStore.DeleteManyTx(ctx, tx, ids), "delete schedules")
case assignment.TargetTypeCalendarSubscription:
Expand Down
39 changes: 39 additions & 0 deletions integrationkey/queries.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
-- name: IntKeyGetServiceID :one
SELECT
service_id
FROM
integration_keys
WHERE
id = $1
AND type = $2;

-- name: IntKeyCreate :exec
INSERT INTO integration_keys(id, name, type, service_id)
VALUES ($1, $2, $3, $4);

-- name: IntKeyFindOne :one
SELECT
id,
name,
type,
service_id
FROM
integration_keys
WHERE
id = $1;

-- name: IntKeyFindByService :many
SELECT
id,
name,
type,
service_id
FROM
integration_keys
WHERE
service_id = $1;

-- name: IntKeyDelete :exec
DELETE FROM integration_keys
WHERE id = ANY (@ids::uuid[]);

Loading