Skip to content

Commit

Permalink
Add delete statement for rule_type_data_sources. (#5097)
Browse files Browse the repository at this point in the history
This statement is necessary to allow updates on Rule Types. Since an
update does not modify the ID, we can't expect cascading deletes to
happen, and thus have to perform the cleanup manually.
  • Loading branch information
blkt authored Dec 2, 2024
1 parent 532e3be commit 1bb8571
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions database/mock/store.go

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

5 changes: 5 additions & 0 deletions database/query/datasources.sql
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ WHERE data_sources_id = $1 AND project_id = $2;
INSERT INTO rule_type_data_sources (rule_type_id, data_sources_id, project_id)
VALUES (sqlc.arg(ruleTypeID)::uuid, sqlc.arg(dataSourceID)::uuid, sqlc.arg(projectID)::uuid)
RETURNING rule_type_id, data_sources_id, project_id;

-- name: DeleteRuleTypeDataSource :exec
DELETE FROM rule_type_data_sources
WHERE rule_type_id = sqlc.arg(ruleid)
AND project_id = sqlc.arg(projectid);
16 changes: 16 additions & 0 deletions internal/db/datasources.sql.go

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

1 change: 1 addition & 0 deletions internal/db/querier.go

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

0 comments on commit 1bb8571

Please sign in to comment.