SQL error when deleting environment

Hi,

When I go to the Puppet Classes screen and click on Import, Foreman prompts
me to remove a deleted environment. When I try to accept the change, I get
the following error:

Mysql2::Error: Cannot delete or update a parent row: a foreign key
constraint fails (foreman.hostgroups, CONSTRAINT
hostgroups_environment_id_fk FOREIGN KEY (environment_id) REFERENCES
environments (id)): DELETE FROM environments WHERE
environments.id = 1

This is on Foreman 1.4.1. Has anyone else run into this issue?

Thanks,

Andy

It looks like one of your host groups still has this environment set, so
you may need to find and change it before you can remove it.

··· On 28/04/14 10:26, Andy Taylor wrote: > Hi, > > When I go to the Puppet Classes screen and click on Import, Foreman > prompts me to remove a deleted environment. When I try to accept the > change, I get the following error: > > Mysql2::Error: Cannot delete or update a parent row: a foreign key > constraint fails (`foreman`.`hostgroups`, CONSTRAINT > `hostgroups_environment_id_fk` FOREIGN KEY (`environment_id`) REFERENCES > `environments` (`id`)): DELETE FROM `environments` WHERE > `environments`.`id` = 1 > > This is on Foreman 1.4.1. Has anyone else run into this issue?


Dominic Cleal
Red Hat Engineering

Thanks Dominic, I removed the hostgroup and the import operation then
worked fine.

Cheers,

Andy

··· On Monday, 28 April 2014 11:24:34 UTC+1, Dominic Cleal wrote: > > On 28/04/14 10:26, Andy Taylor wrote: > > Hi, > > > > When I go to the Puppet Classes screen and click on Import, Foreman > > prompts me to remove a deleted environment. When I try to accept the > > change, I get the following error: > > > > Mysql2::Error: Cannot delete or update a parent row: a foreign key > > constraint fails (`foreman`.`hostgroups`, CONSTRAINT > > `hostgroups_environment_id_fk` FOREIGN KEY (`environment_id`) REFERENCES > > `environments` (`id`)): DELETE FROM `environments` WHERE > > `environments`.`id` = 1 > > > > This is on Foreman 1.4.1. Has anyone else run into this issue? > > It looks like one of your host groups still has this environment set, so > you may need to find and change it before you can remove it. > > -- > Dominic Cleal > Red Hat Engineering >