Skip to content
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
5a5fe0a
move deletion async
adelowo Jan 21, 2026
597f9b1
register event listener in tests
adelowo Jan 21, 2026
9b7f50a
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Jan 22, 2026
e6a5990
fix edge deletions
adelowo Jan 22, 2026
522e471
review fixes
adelowo Jan 22, 2026
738f293
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Jan 26, 2026
8483188
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Jan 26, 2026
2cafd00
task generate
adelowo Jan 26, 2026
8166725
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Jan 26, 2026
8b2f2bd
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Mar 18, 2026
c01f22a
revert listener
adelowo Mar 18, 2026
333ecc5
revert listener
adelowo Mar 18, 2026
a8800ed
fix bad merge
adelowo Mar 18, 2026
53e9eaf
fix tests
adelowo Mar 18, 2026
1513edb
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Apr 8, 2026
bfc7ed5
task regenerate
adelowo Apr 8, 2026
0ae5361
add edge deletion for org
adelowo Apr 9, 2026
93b64dd
use custom enum skip
adelowo Apr 9, 2026
6fe7741
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Apr 9, 2026
c1d9e29
enable entitlement for cascade deletion test
adelowo Apr 10, 2026
259e5d4
add pending_deletion_at
adelowo Apr 10, 2026
564f512
remove update skip
adelowo Apr 10, 2026
5ee5082
Merge remote-tracking branch 'origin/main' into feat-1732
adelowo Apr 13, 2026
f9570a3
task db:create
adelowo Apr 13, 2026
5063fd0
allow mutation of org_settings by system admin
adelowo Apr 14, 2026
fd26041
admin should be able to fetch org members
adelowo Apr 14, 2026
8cd1dcd
Drop organizationid property as it would be a periodic job
adelowo Apr 14, 2026
d1fd44c
allow admin mutation
adelowo Apr 14, 2026
0587573
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 14, 2026
31fa5d8
task regenerate
adelowo Apr 14, 2026
09f6892
Merge remote-tracking branch 'origin/main' into enhance-ISS-920
adelowo Apr 14, 2026
66b9073
task regenerate
adelowo Apr 14, 2026
0ca2ddf
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 15, 2026
7045b09
task regenerate
adelowo Apr 15, 2026
8b29009
bump gomarkdown up to fix vuln
adelowo Apr 15, 2026
e5e360a
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 15, 2026
bb433be
task regenerate
adelowo Apr 15, 2026
4656739
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 16, 2026
f63c433
task regenerate
adelowo Apr 16, 2026
aecd8f8
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 17, 2026
79f8bd1
task db:create
adelowo Apr 20, 2026
38ed015
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 22, 2026
30494b0
task regenerate
adelowo Apr 22, 2026
101fa57
Merge branch 'main' into feat-ISS-1732
adelowo Apr 23, 2026
52067ac
Merge branch 'main' into feat-ISS-1732
adelowo Apr 24, 2026
3fcbad0
Update internal/ent/hooks/customenums.go
adelowo Apr 24, 2026
21afdbe
try entc fix
adelowo Apr 24, 2026
ff990e9
Merge remote-tracking branch 'origin/enhance-ISS-920' into feat-ISS-1732
adelowo Apr 24, 2026
f239321
fix merge conflict
adelowo Apr 24, 2026
fa180b4
Merge remote-tracking branch 'origin/main' into feat-ISS-1732
adelowo Apr 27, 2026
b07add7
fix tests
adelowo Apr 27, 2026
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
2 changes: 1 addition & 1 deletion .task/checksum/generate-ent-smart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c532c06aa054e80e1b50e8587e9f6d3c
5a715b91ca7219cba80e2f8aac01ad6f
2 changes: 1 addition & 1 deletion .task/checksum/generate-graphql-smart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
54e5e3c3d76e71451c97ad7b4abc414b
fa663ecfd53a07e36e31ea824f492e20
5 changes: 1 addition & 4 deletions common/jobspec/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ func (OrganizationDeletionReminderArgs) InsertOpts() river.InsertOpts {
}

// OrganizationDeletionReminderArgs for the periodic worker to delete an organization
type OrganizationDeletionArgs struct {
// OrganizationID is the organization that is deleted
OrganizationID string `json:"organization_id"`
}
type OrganizationDeletionArgs struct{}

// Kind satisfies the river.Job interface
func (OrganizationDeletionArgs) Kind() string { return "org_deletion" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- +goose Up
-- modify "organization_settings" table
ALTER TABLE "organization_settings" ADD COLUMN "pending_deletion_at" timestamptz NULL;

-- +goose Down
-- reverse: modify "organization_settings" table
ALTER TABLE "organization_settings" DROP COLUMN "pending_deletion_at";
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- +goose Up
-- modify "organization_setting_history" table
ALTER TABLE "organization_setting_history" ADD COLUMN "pending_deletion_at" timestamptz NULL;

-- +goose Down
-- reverse: modify "organization_setting_history" table
ALTER TABLE "organization_setting_history" DROP COLUMN "pending_deletion_at";
4 changes: 3 additions & 1 deletion db/migrations-goose-postgres/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:93l9wk61QpyU3p0afFNY3K2AaiUwydnW7LeEjfUxNY8=
h1:77tJi+/yyYPSk3oV8CW/QkVbTTgRmF5QDakJNM1zb2Y=
20251229183203_init.sql h1:g/05irCXoqKFObJV2PPLuvDRqma+da41VPsZ5fXQgfE=
20251229183205_init_history.sql h1:P/q2kAHb8zfNMOWzYkKtPbOwoh9GdJUQljSNAiPEjYI=
20251231045229_workflow.sql h1:uUPRLO4yw2y//fPGeqIXRrL+fiEN1TRGkF4wHiqPaPk=
Expand Down Expand Up @@ -117,3 +117,5 @@ h1:93l9wk61QpyU3p0afFNY3K2AaiUwydnW7LeEjfUxNY8=
20260417045841_integrations_directory_accounts_history.sql h1:X+BkbIMBENfr2PKUb39JwoJLw/EVNEuMgZoT6Ftz6q4=
20260417200313_file_category_and_name.sql h1:XpUXRyLZswyLIG8Xqk+yR6jIonIVncp4beFnffrwm50=
20260417200323_file_category_and_name_history.sql h1:KW0FYnvmQQ5DQiAsgtB/xQSokP3N6UHi1yC6Oi4LOXU=
20260420125531_organization_setting_pending_deletion_at.sql h1:3JbK+6fXYvRJ3RPtN3s1GkdZASupXGQCLAxA600bzW8=
20260420125541_organization_setting_pending_deletion_at_history.sql h1:f2IWz2YuqDja9t1SM/sGZLo2EJFHHh5Cm2M1G4yCrdg=
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "organization_settings" table
ALTER TABLE "organization_settings" ADD COLUMN "pending_deletion_at" timestamptz NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "organization_setting_history" table
ALTER TABLE "organization_setting_history" ADD COLUMN "pending_deletion_at" timestamptz NULL;
4 changes: 3 additions & 1 deletion db/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
h1:eqT50oHZlb2TX3kOKima//k24jZ65HcwqxuRMVoPCb4=
h1:O9JQFdGfzaYL5Ily7YexSO4xjN+W24fPmXWtLmZuo74=
20251229183159_init.sql h1:3uf/ftr28zW8YUD9qAaY2GESQHC7pYmkhlI6oDWUCKU=
20251229183201_init_history.sql h1:1tFSeCDWvZgb2Ctw80C/s3tqVPNLADQw9fSDACzL8WA=
20251231045221_workflow.sql h1:5bLq4cHh2kxUV7xajK5bq5McKKpr88HmufYauTdsgUw=
Expand Down Expand Up @@ -117,3 +117,5 @@ h1:eqT50oHZlb2TX3kOKima//k24jZ65HcwqxuRMVoPCb4=
20260417045833_integrations_directory_accounts_history.sql h1:/1iTo0qzLR0WCNtTkzHjf7PWacJ08ptOQRV6LVrNBLQ=
20260417200247_file_category_and_name.sql h1:CeHehsDn2+g81Om5s0kF1Pkg+KNkAw2j826hjR7R5RM=
20260417200300_file_category_and_name_history.sql h1:gp5j8slOUzZeenBswbm4a2D3nvV1XaT5nZs7cvB8Jtg=
20260420125504_organization_setting_pending_deletion_at.sql h1:eKiagvLL7IOpb2cztyekrwGGyBxGS8fiaWnC4VT5DZY=
20260420125516_organization_setting_pending_deletion_at_history.sql h1:mzIOLV8TnvSEx3GISsL/PbLw5aKz63FR8u/OHp8QjMA=
2 changes: 1 addition & 1 deletion internal/ent/checksum/.history_schema_checksum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
efd48930f2cba0fb370a288c49bf5916d22899ab03e7c7e06b5a02e5b69d7722
6a207b60daf10323cef10cb80efeffd0f8fd304aca7e3bdb9622c80038270c99
2 changes: 1 addition & 1 deletion internal/ent/checksum/.schema_checksum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f2b07aa110f1340e2d85b9713ca56d0f4b381d8f6bd01f12a5e5a867230255eb
2aff7ebf2013e6ced212b25fc3fa7ad3b1e5113f5220b789b9316e8bc8d32444
28 changes: 15 additions & 13 deletions internal/ent/generate/entc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ import (
_ "github.com/jackc/pgx/v5"
"gocloud.dev/secrets"

"github.com/theopenlane/core/common/enums/exportenums"
"github.com/theopenlane/core/internal/ent/entconfig"
"github.com/theopenlane/core/internal/ent/filecategorygen"
"github.com/theopenlane/core/internal/ent/historygenerated"
"github.com/theopenlane/core/internal/ent/validator"
"github.com/theopenlane/core/internal/entitlements/genfeatures"
"github.com/theopenlane/core/internal/genhelpers"
"github.com/theopenlane/core/internal/graphapi/directives"
"github.com/theopenlane/core/internal/objects"
"github.com/theopenlane/core/pkg/entitlements"
"github.com/theopenlane/core/pkg/gala"
"github.com/theopenlane/core/pkg/shortlinks"
"github.com/theopenlane/core/pkg/summarizer"
"github.com/theopenlane/emailtemplates"
"github.com/theopenlane/entx"
"github.com/theopenlane/entx/accessmap"
Expand All @@ -44,6 +31,20 @@ import (
"github.com/theopenlane/iam/sessions"
"github.com/theopenlane/iam/tokens"
"github.com/theopenlane/iam/totp"

"github.com/theopenlane/core/common/enums/exportenums"
"github.com/theopenlane/core/internal/ent/entconfig"
"github.com/theopenlane/core/internal/ent/filecategorygen"
"github.com/theopenlane/core/internal/ent/historygenerated"
"github.com/theopenlane/core/internal/ent/validator"
"github.com/theopenlane/core/internal/entitlements/genfeatures"
"github.com/theopenlane/core/internal/genhelpers"
"github.com/theopenlane/core/internal/graphapi/directives"
"github.com/theopenlane/core/internal/objects"
"github.com/theopenlane/core/pkg/entitlements"
"github.com/theopenlane/core/pkg/gala"
"github.com/theopenlane/core/pkg/shortlinks"
"github.com/theopenlane/core/pkg/summarizer"
)

var (
Expand Down Expand Up @@ -359,6 +360,7 @@ func runParallelPostGenHooks(g *gen.Graph) {
integrationmapping.WithDoPackage("github.com/samber/do/v2"),
integrationmapping.WithLoPackage("github.com/samber/lo"),
integrationmapping.WithJsonxPackage("github.com/theopenlane/core/pkg/jsonx"),
integrationmapping.WithLogxPackage("github.com/theopenlane/core/pkg/logx"),
).Hook(),
accessMapExt.Hook(),
fileCategoryGen.Hook(),
Expand Down
28 changes: 28 additions & 0 deletions internal/ent/generate/templates/ent/edge_cleanup.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,26 @@
{{ $pkg := base $.Config.Package }}
{{ template "header" $ }}

import (
"github.com/theopenlane/core/internal/ent/hooks/contextx"
)

{{/* For each schema */}}
{{- range $node := $.Nodes }}
{{/* create an EdgeCleanup function accepting an ID */}}
func {{ $node.Name }}EdgeCleanup(ctx context.Context, id string) error {
ctx = entfga.WithDeleteTuplesFirst(privacy.DecisionContext(ctx, privacy.Allowf("cleanup {{ $node.Name | lower }} edge")))

{{- if eq $node.Name "Organization" }}
ctx = contextx.WithSkipEnumInUseCheck(ctx)
if exists, err := FromContext(ctx).CustomTypeEnum.Query().Where((customtypeenum.HasOwnerWith(organization.ID(id)))).Exist(ctx); err == nil && exists {
if customtypeenumCount, err := FromContext(ctx).CustomTypeEnum.Delete().Where(customtypeenum.HasOwnerWith(organization.ID(id))).Exec(ctx); err != nil {
logx.FromContext(ctx).Error().Err(err).Int("count", customtypeenumCount).Msg("error deleting customtypeenum")
return err
}
}
{{- end }}

{{/* For each edge */}}
{{- range $edge := $node.Edges }}
{{/* if the edge has our custom annotation applied */}}
Expand All @@ -34,6 +48,20 @@
}
}
{{- else }}
{{/* clean up nested edges before deleting */}}
{
ids, err := FromContext(ctx).{{ $edge.Type.Name }}.Query().Where({{ $edge.Type.Name | lower }}.Has{{ $annotation.Field }}With({{ $node.Name | lower }}.ID(id))).IDs(ctx)
if err != nil {
logx.FromContext(ctx).Error().Err(err).Msg("error querying {{ $edge.Type.Name | lower }} ids for cleanup")
return err
}
for _, edgeID := range ids {
if err := {{ $edge.Type.Name }}EdgeCleanup(ctx, edgeID); err != nil {
logx.FromContext(ctx).Error().Err(err).Str("id", edgeID).Msg("error cleaning up {{ $edge.Type.Name | lower }} edges")
return err
}
}
}
if exists, err := FromContext(ctx).{{ $edge.Type.Name }}.Query().Where(({{ $edge.Type.Name | lower }}.Has{{ $annotation.Field }}With({{ $node.Name | lower }}.ID(id)))).Exist(ctx); err == nil && exists {
if {{ $edge.Type.Name | lower }}Count, err := FromContext(ctx).{{ $edge.Type.Name }}.Delete().Where({{ $edge.Type.Name | lower }}.Has{{ $annotation.Field }}With({{ $node.Name | lower }}.ID(id))).Exec(ctx); err != nil {
logx.FromContext(ctx).Error().Err(err).Int("count", {{ $edge.Type.Name | lower }}Count).Msg("error deleting {{ $edge.Type.Name | lower }}")
Expand Down
Loading
Loading