[racktables-users] Re: query failed on upgrade to 0.17.6

  • From: Denis Ovsienko <infrastation@xxxxxxxxx>
  • To: racktables-users@xxxxxxxxxxxxx
  • Date: Sun, 22 Nov 2009 23:18:24 +0300

Hello.

>  > > This brings up the question... how do I check if there are more such
>  > > entries in the Link database?
>  > 
>  > SELECT * FROM Link WHERE porta NOT IN (SELECT id FROM Port) OR portb
>  > NOT IN (SELECT id FROM Port);
>  
>  Done that, found 26 invalid entries...

[...]

>  I'm not quite fit in adding constraints to an existing table. Before I
>  break my installation, could you tell me how to safely do that?

Well, the way to fix this constraint issue is trivial:

DELETE FROM Link WHERE porta NOT IN (SELECT id FROM Port) OR portb NOT IN 
(SELECT id FROM Port);
ALTER TABLE Link ADD CONSTRAINT `Link-FK-b` FOREIGN KEY (portb) REFERENCES Port 
(id);
ALTER TABLE Link ADD CONSTRAINT `Link-FK-a` FOREIGN KEY (porta) REFERENCES Port 
(id);

What is really strange is that the upgrade script had either to add the keys or 
to fail (and bring the error to your attention). Anyway, let's try and see if 
it helps.

-- 
    Denis Ovsienko

Other related posts: