Skip to content

ROX-18202: Fix language layer error due to unique constraint #1223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 14 additions & 0 deletions database/pgsql/migrations/00020_languagelayer_lineage_pk.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package migrations

import "github.com/remind101/migrate"

func init() {
RegisterMigration(migrate.Migration{
ID: 20,
Up: migrate.Queries([]string{
`ALTER TABLE LanguageLayer DROP CONSTRAINT IF EXISTS languagelayer_pkey`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this a generic, default constraint? I don't see it in my deployment:

postgres=# \d languagelayer
                         Table "public.languagelayer"
       Column       |          Type          | Collation | Nullable | Default 
--------------------+------------------------+-----------+----------+---------
 layer_id           | integer                |           | not null | 
 layer_name         | character varying(128) |           | not null | 
 component_data     | bytea                  |           | not null | 
 removed_components | text[]                 |           |          | 
 lineage            | character varying      |           |          | 
Indexes:
    "languagelayer_layer_name_key" UNIQUE CONSTRAINT, btree (layer_name)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

languagelayer_pkey is the name of the constraint after ALTER TABLE LanguageLayer ADD PRIMARY KEY (layer_name, lineage) is applied, the default name of a primary key looks to be <table name>_pkey

Possibly added to the migration so that it would not cause errors if re-ran.

`ALTER TABLE LanguageLayer DROP CONSTRAINT IF EXISTS languagelayer_layer_name_key`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so dropping this constraint removes the UNIQUE part of layer_name VARCHAR(128) NOT NULL UNIQUE?

`ALTER TABLE LanguageLayer ADD PRIMARY KEY (layer_name, lineage)`,
}),
})
}
18 changes: 18 additions & 0 deletions e2etests/vuln_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,24 @@ func TestStackroxVulnImages(t *testing.T) {
},
},
},
{
image: "quay.io/rhacs-eng/qa:drools-debian",
expectedFeatures: []feature{
{"drools", "6.4.0.final", []expectedVuln{
{name: "CVE-2021-41411", fixedBy: ""},
},
},
},
},
{
image: "quay.io/rhacs-eng/qa:drools-ubi-minimal",
expectedFeatures: []feature{
{"drools", "6.4.0.final", []expectedVuln{
{name: "CVE-2021-41411", fixedBy: ""},
},
},
},
},
} {
t.Run(testCase.image, func(t *testing.T) {
testSingleVulnImage(testCase, t)
Expand Down