diff --git a/CLAUDE.md b/CLAUDE.md index b7b050240..1f3099174 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -256,4 +256,5 @@ Code reviews are required for all submissions via GitHub pull requests. - I do not want you to be in the co-author signoff -- make sure all go code is go-fmt \ No newline at end of file +- make sure all go code is go-fmt +- when the schema is changed, run make generate, do not create a migration explicitly \ No newline at end of file diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/20250812111458.sql b/app/controlplane/pkg/data/ent/migrate/migrations/20250812111458.sql new file mode 100644 index 000000000..10a8962e9 --- /dev/null +++ b/app/controlplane/pkg/data/ent/migrate/migrations/20250812111458.sql @@ -0,0 +1,2 @@ +-- Modify "attestations" table +ALTER TABLE "attestations" DROP CONSTRAINT "attestations_workflow_runs_attestation_bundle", ADD CONSTRAINT "attestations_workflow_runs_attestation_bundle" FOREIGN KEY ("workflowrun_id") REFERENCES "workflow_runs" ("id") ON UPDATE NO ACTION ON DELETE CASCADE; diff --git a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum index 5cebbfdf9..c3c36182b 100644 --- a/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum +++ b/app/controlplane/pkg/data/ent/migrate/migrations/atlas.sum @@ -1,4 +1,4 @@ -h1:CR4ZZX0wKUI9H+dldKzHZ2IkDpnRSTyssXoCkVJk31g= +h1:QaClWT8b1Nr8BRNI+5O2WAYbWl/5tTlopLggA6RQwzw= 20230706165452_init-schema.sql h1:VvqbNFEQnCvUVyj2iDYVQQxDM0+sSXqocpt/5H64k8M= 20230710111950-cas-backend.sql h1:A8iBuSzZIEbdsv9ipBtscZQuaBp3V5/VMw7eZH6GX+g= 20230712094107-cas-backends-workflow-runs.sql h1:a5rzxpVGyd56nLRSsKrmCFc9sebg65RWzLghKHh5xvI= @@ -107,3 +107,4 @@ h1:CR4ZZX0wKUI9H+dldKzHZ2IkDpnRSTyssXoCkVJk31g= 20250808164000.sql h1:T6Yt5JhbfB+7iY4WPpeCEsT3G5wplxTBB64De3ZXNus= 20250808164400.sql h1:r7S2LM8d3kbKQ7WNuggjvmNw3kcccx0rYzzklw8Q2I8= 20250808165202.sql h1:Oreh9FpYwo/cdcs3Oza/+ACzScXeTRBGIEvua8RqoLo= +20250812111458.sql h1:15yQlZoBymYR5GEjGLtV/j4ZZjg06u6eEzcRRl7vax4= diff --git a/app/controlplane/pkg/data/ent/migrate/schema.go b/app/controlplane/pkg/data/ent/migrate/schema.go index 360ab5dbf..b4db1be31 100644 --- a/app/controlplane/pkg/data/ent/migrate/schema.go +++ b/app/controlplane/pkg/data/ent/migrate/schema.go @@ -76,7 +76,7 @@ var ( Symbol: "attestations_workflow_runs_attestation_bundle", Columns: []*schema.Column{AttestationsColumns[3]}, RefColumns: []*schema.Column{WorkflowRunsColumns[0]}, - OnDelete: schema.NoAction, + OnDelete: schema.Cascade, }, }, } diff --git a/app/controlplane/pkg/data/ent/schema/workflowrun.go b/app/controlplane/pkg/data/ent/schema/workflowrun.go index 4794138c6..e36bbf781 100644 --- a/app/controlplane/pkg/data/ent/schema/workflowrun.go +++ b/app/controlplane/pkg/data/ent/schema/workflowrun.go @@ -73,7 +73,7 @@ func (WorkflowRun) Edges() []ent.Edge { edge.To("cas_backends", CASBackend.Type), // not required since we have old data edge.From("version", ProjectVersion.Type).Field("version_id").Ref("runs").Unique().Required(), - edge.To("attestation_bundle", Attestation.Type).Unique(), + edge.To("attestation_bundle", Attestation.Type).Unique().Annotations(entsql.Annotation{OnDelete: entsql.Cascade}), } }