Skip to content

Commit

Permalink
update dependency schema to make dependent_package_version_id required (
Browse files Browse the repository at this point in the history
guacsec#2060)

* update dependency schema to make dependent_package_version_id required

Signed-off-by: pxp928 <[email protected]>

* update dependent_package_version_id to be not null on dependency table

Signed-off-by: pxp928 <[email protected]>

---------

Signed-off-by: pxp928 <[email protected]>
  • Loading branch information
pxp928 authored Aug 6, 2024
1 parent 5e25e14 commit c4b6a42
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 78 deletions.
10 changes: 0 additions & 10 deletions pkg/assembler/backends/ent/dependency/where.go

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

34 changes: 6 additions & 28 deletions pkg/assembler/backends/ent/dependency_create.go

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

18 changes: 6 additions & 12 deletions pkg/assembler/backends/ent/dependency_update.go

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

2 changes: 1 addition & 1 deletion pkg/assembler/backends/ent/gql_edge.go

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- Modify "dependencies" table
ALTER TABLE "dependencies" ALTER COLUMN "dependent_package_version_id" SET NOT NULL;
3 changes: 2 additions & 1 deletion pkg/assembler/backends/ent/migrate/migrations/atlas.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
h1:2v3i5iU6MalDXCn9jNXp+75vnIcNccKwMbKG2r1uBkc=
h1:mYbfXOAYvSgAht05+9wroDncH1ZJDdll9KZ1sDjie30=
20240503123155_baseline.sql h1:oZtbKI8sJj3xQq7ibfvfhFoVl+Oa67CWP7DFrsVLVds=
20240626153721_ent_diff.sql h1:FvV1xELikdPbtJk7kxIZn9MhvVVoFLF/2/iT/wM5RkA=
20240702195630_ent_diff.sql h1:y8TgeUg35krYVORmC7cN4O96HqOc3mVO9IQ2lYzIzwg=
20240712131658_ent_diff.sql h1:N54EB3Wh2NC2v9RToXo/BfpezLnSeHJBP1ha6VXfxD8=
20240712193834_ent_diff.sql h1:gHTfEzlqvgYi6NKwT/Mb+wooWsVjAkp98zfg1OvdoZw=
20240716182144_ent_diff.sql h1:Pm0/+7zkBUGOY/AiF3bCJzW8giL5+uSg/j/0SUDsuNg=
20240802204508_ent_diff.sql h1:+qucLy0vqkEDoJsfG4Phh+babyGB5Ud/Dn0+WNB6BLY=
2 changes: 1 addition & 1 deletion pkg/assembler/backends/ent/migrate/schema.go

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

26 changes: 2 additions & 24 deletions pkg/assembler/backends/ent/mutation.go

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

3 changes: 2 additions & 1 deletion pkg/assembler/backends/ent/schema/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (Dependency) Fields() []ent.Field {
Unique().
Immutable(),
field.UUID("package_id", getUUIDv7()),
field.UUID("dependent_package_version_id", getUUIDv7()).Optional(),
field.UUID("dependent_package_version_id", getUUIDv7()),
field.Enum("dependency_type").Values(model.DependencyTypeDirect.String(), model.DependencyTypeIndirect.String(), model.DependencyTypeUnknown.String()),
field.String("justification"),
field.String("origin"),
Expand All @@ -63,6 +63,7 @@ func (Dependency) Edges() []ent.Edge {
Field("package_id").
Unique().Annotations(entsql.OnDelete(entsql.Cascade)),
edge.To("dependent_package_version", PackageVersion.Type).
Required().
Field("dependent_package_version_id").
Unique().Annotations(entsql.OnDelete(entsql.Cascade)),
edge.From("included_in_sboms", BillOfMaterials.Type).Ref("included_dependencies").Annotations(entsql.OnDelete(entsql.Cascade)),
Expand Down

0 comments on commit c4b6a42

Please sign in to comment.