Skip to content

Commit

Permalink
Fix auth delete when GitHub App installed (#2904)
Browse files Browse the repository at this point in the history
Add missing cascade delete
  • Loading branch information
eleftherias authored Apr 2, 2024
1 parent afc0545 commit 0ee5660
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

BEGIN;

ALTER TABLE provider_github_app_installations
DROP CONSTRAINT provider_github_app_installations_project_id_fkey;

ALTER TABLE provider_github_app_installations
ADD CONSTRAINT provider_github_app_installations_project_id_fkey
FOREIGN KEY (project_id)
REFERENCES projects(id);

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-- Copyright 2024 Stacklok, Inc
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.

BEGIN;

-- drop the existing foreign key constraint on project_id
ALTER TABLE provider_github_app_installations
DROP CONSTRAINT provider_github_app_installations_project_id_fkey;

-- create a new foreign key constraint on project_id with ON DELETE CASCADE
ALTER TABLE provider_github_app_installations
ADD CONSTRAINT provider_github_app_installations_project_id_fkey
FOREIGN KEY (project_id)
REFERENCES projects(id)
ON DELETE CASCADE;

COMMIT;

0 comments on commit 0ee5660

Please sign in to comment.