Skip to content

Commit

Permalink
drop discovered_license from required index as it is covered by the d…
Browse files Browse the repository at this point in the history
…iscovered_license_hash (#2139)

Signed-off-by: pxp928 <[email protected]>
  • Loading branch information
pxp928 authored Sep 19, 2024
1 parent f5e60a9 commit 9dbf407
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
1 change: 0 additions & 1 deletion pkg/assembler/backends/ent/backend/certifyLegal.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ func (b *EntBackend) IngestCertifyLegals(ctx context.Context, subjects model.Pac
func certifyLegalConflictColumns() []string {
return []string{
certifylegal.FieldDeclaredLicense,
certifylegal.FieldDiscoveredLicense,
certifylegal.FieldJustification,
certifylegal.FieldTimeScanned,
certifylegal.FieldOrigin,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Drop index "certifylegal_package_id_declared_license_discovered_license_jus" from table: "certify_legals"
DROP INDEX "certifylegal_package_id_declared_license_discovered_license_jus";
-- Drop index "certifylegal_source_id_declared_license_discovered_license_just" from table: "certify_legals"
DROP INDEX "certifylegal_source_id_declared_license_discovered_license_just";
-- Create index "certifylegal_package_id_declared_license_justification_time_sca" to table: "certify_legals"
CREATE UNIQUE INDEX "certifylegal_package_id_declared_license_justification_time_sca" ON "certify_legals" ("package_id", "declared_license", "justification", "time_scanned", "origin", "collector", "document_ref", "declared_licenses_hash", "discovered_licenses_hash") WHERE ((package_id IS NOT NULL) AND (source_id IS NULL));
-- Create index "certifylegal_source_id_declared_license_justification_time_scan" to table: "certify_legals"
CREATE UNIQUE INDEX "certifylegal_source_id_declared_license_justification_time_scan" ON "certify_legals" ("source_id", "declared_license", "justification", "time_scanned", "origin", "collector", "document_ref", "declared_licenses_hash", "discovered_licenses_hash") WHERE ((package_id IS NULL) AND (source_id IS 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,4 +1,4 @@
h1:4m5T/TgdBGibMa72PIaSuAkf+RI5hL1fQLxBH53lRas=
h1:3eRFoV2cM7hzSkmdDQ8HwhoF99Mp0L9r4o4UFWTzXe4=
20240503123155_baseline.sql h1:oZtbKI8sJj3xQq7ibfvfhFoVl+Oa67CWP7DFrsVLVds=
20240626153721_ent_diff.sql h1:FvV1xELikdPbtJk7kxIZn9MhvVVoFLF/2/iT/wM5RkA=
20240702195630_ent_diff.sql h1:y8TgeUg35krYVORmC7cN4O96HqOc3mVO9IQ2lYzIzwg=
Expand All @@ -8,3 +8,4 @@ h1:4m5T/TgdBGibMa72PIaSuAkf+RI5hL1fQLxBH53lRas=
20240802204508_ent_diff.sql h1:+qucLy0vqkEDoJsfG4Phh+babyGB5Ud/Dn0+WNB6BLY=
20240826162616_ent_diff.sql h1:VyzOoAHvz3Ct8o/nva5qmyFzPOVmrJnXlrwpUCwoCHw=
20240918165345.sql h1:wpfJhr9rJSWWzbTA85rnLppDjGscJVaFpE1uZJXpScY=
20240919142722_ent_diff.sql h1:hcb42aHj5QUwbd7HXsUFnnAzHIckdXfGRDNYa24rns8=
8 changes: 4 additions & 4 deletions pkg/assembler/backends/ent/migrate/schema.go

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

4 changes: 2 additions & 2 deletions pkg/assembler/backends/ent/schema/certifylegal.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ func (CertifyLegal) Edges() []ent.Edge {

func (CertifyLegal) Indexes() []ent.Index {
return []ent.Index{
index.Fields("source_id", "declared_license", "discovered_license", "justification", "time_scanned",
index.Fields("source_id", "declared_license", "justification", "time_scanned",
"origin", "collector", "document_ref", "declared_licenses_hash", "discovered_licenses_hash").
Unique().
Annotations(entsql.IndexWhere("package_id IS NULL AND source_id IS NOT NULL")),
index.Fields("package_id", "declared_license", "discovered_license", "justification", "time_scanned",
index.Fields("package_id", "declared_license", "justification", "time_scanned",
"origin", "collector", "document_ref", "declared_licenses_hash", "discovered_licenses_hash").
Unique().
Annotations(entsql.IndexWhere("package_id IS NOT NULL AND source_id IS NULL")),
Expand Down

0 comments on commit 9dbf407

Please sign in to comment.