Bug 1589625
Summary: | no unique constraint to the name column on the roles table | ||
---|---|---|---|
Product: | Red Hat Satellite | Reporter: | matt jia <mjia> |
Component: | Users & Roles | Assignee: | Dominik Hlavac Duran <dhlavacd> |
Status: | CLOSED ERRATA | QA Contact: | jcallaha |
Severity: | medium | Docs Contact: | |
Priority: | unspecified | ||
Version: | 6.3.1 | CC: | dhlavacd, inecas, jhutar, mhulan, mjia, pcreech |
Target Milestone: | 6.5.0 | Keywords: | EasyFix, Triaged |
Target Release: | Unused | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2019-05-14 12:37:23 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: | |||
Bug Depends On: | |||
Bug Blocks: | 1713769 |
Description
matt jia
2018-06-11 02:08:26 UTC
Adding an index should work. create UNIQUE INDEX "index_roles_on_name" on roles using btree (name);\ On Snap7: # sudo -u foreman psql foreman psql (9.2.23) Type "help" for help. foreman=> \d roles Table "public.roles" Column | Type | Modifiers ----------------+------------------------+---------------------------------------------------- id | integer | not null default nextval('roles_id_seq'::regclass) name | character varying(255) | builtin | integer | default 0 description | text | origin | character varying | cloned_from_id | integer | Indexes: "roles_pkey" PRIMARY KEY, btree (id) Referenced by: TABLE "filters" CONSTRAINT "filters_roles_id_fk" FOREIGN KEY (role_id) REFERENCES roles(id) TABLE "user_roles" CONSTRAINT "user_roles_role_id_fk" FOREIGN KEY (role_id) REFERENCES roles(id) foreman=> insert into roles(name, origin) values('ABC', 'abc'); INSERT 0 1 foreman=> insert into roles(name, origin) values('ABC', 'abc'); INSERT 0 1 Upstream bug assigned to dhlavacd Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/24002 has been resolved. The original steps still fail, however i do see the unique index mentioned in the above comment. Is this the result you were going for? -bash-4.2# su - postgres -bash-4.2$ psql foreman psql (9.2.24) Type "help" for help. foreman=# insert into roles(name, origin) values('Access Insights Admin', 'redhat_access'); ERROR: duplicate key value violates unique constraint "index_roles_on_name" DETAIL: Key (name)=(Access Insights Admin) already exists. foreman=# foreman=# \d roles; Table "public.roles" Column | Type | Modifiers ----------------+------------------------+---------------------------------------------------- id | integer | not null default nextval('roles_id_seq'::regclass) name | character varying(255) | builtin | integer | default 0 description | text | origin | character varying | cloned_from_id | integer | Indexes: "roles_pkey" PRIMARY KEY, btree (id) "index_roles_on_name" UNIQUE, btree (name) Referenced by: TABLE "filters" CONSTRAINT "filters_roles_id_fk" FOREIGN KEY (role_id) REFERENCES roles(id) TABLE "user_roles" CONSTRAINT "user_roles_role_id_fk" FOREIGN KEY (role_id) REFERENCES roles(id) Hi, yes this is expected result because if you want to enter role with same name it don't allow you to do that. After adding index on name is not possible to create duplicate entry with same name in db. Verified in Satellite 6.5.0 Snap 12, based on results in #9 and clarification in #10. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2019:1222 |