Description of problem: The role name is unique. However, this doesn't reflect in the underline db. Version-Release number of selected component (if applicable): 6.3.1 How reproducible: Easy Steps to Reproduce: 1. su - postgres 2. psql foreman 3. insert into roles(name, origin) values('Access Insights Admin', 'redhat_access'); Actual results: Duplicate records for 'Access Insights Admin' Expected results: No duplicate record.
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