Skip to content

Commit 22c4808

Browse files
committed
Merge branch 'main' of github.com:l3montree-dev/devguard
2 parents 02c1845 + 7874f85 commit 22c4808

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Copyright (C) 2026 l3montree GmbH
2+
--
3+
-- This program is free software: you can redistribute it and/or modify
4+
-- it under the terms of the GNU Affero General Public License as
5+
-- published by the Free Software Foundation, either version 3 of the
6+
-- License, or (at your option) any later version.
7+
--
8+
-- This program is distributed in the hope that it will be useful,
9+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
-- GNU Affero General Public License for more details.
12+
--
13+
-- You should have received a copy of the GNU Affero General Public License
14+
-- along with this program. If not, see <https://www.gnu.org/licenses/>.
15+
16+
ALTER TABLE public.external_user_orgs
17+
DROP CONSTRAINT IF EXISTS fk_external_user_orgs_org;
18+
19+
ALTER TABLE public.external_user_orgs
20+
ADD CONSTRAINT fk_external_user_orgs_org
21+
FOREIGN KEY (org_id) REFERENCES public.organizations(id) ON DELETE CASCADE;
22+
23+
ALTER TABLE public.external_user_orgs
24+
DROP CONSTRAINT IF EXISTS fk_external_user_orgs_external_user;
25+
26+
ALTER TABLE public.external_user_orgs
27+
ADD CONSTRAINT fk_external_user_orgs_external_user
28+
FOREIGN KEY (external_user_id) REFERENCES public.external_users(id) ON DELETE CASCADE;

database/models/github_model.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ type ExternalUser struct {
4444
ID string `json:"id" gorm:"primaryKey"`
4545
Username string `json:"username"`
4646
AvatarURL string `json:"avatarUrl"`
47-
Organizations []Org `json:"orgs" gorm:"many2many:external_user_orgs;"`
47+
Organizations []Org `json:"orgs" gorm:"many2many:external_user_orgs;constraint:OnDelete:CASCADE;"`
4848
}
4949

5050
func (ExternalUser) TableName() string {

0 commit comments

Comments
 (0)