Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

FOREIGN KEY migration of syntax, help needed



Hi,

   Quick question:

   My old database has the old-style FOREIGN KEY syntax:

CREATE CONSTRAINT TRIGGER "<unnamed>"
    AFTER INSERT OR UPDATE ON assettype
    FROM assettype
    NOT DEFERRABLE INITIALLY IMMEDIATE
    FOR EACH ROW
    EXECUTE PROCEDURE "RI_FKey_check_ins"('<unnamed>', 'assettype', 'assettype', 'UNSPECIFIED', 'pid', 'id');

CREATE CONSTRAINT TRIGGER "<unnamed>"
    AFTER DELETE ON assettype
    FROM assettype
    NOT DEFERRABLE INITIALLY IMMEDIATE
    FOR EACH ROW
    EXECUTE PROCEDURE "RI_FKey_cascade_del"('<unnamed>', 'assettype', 'assettype', 'UNSPECIFIED', 'pid', 'id');

CREATE CONSTRAINT TRIGGER "<unnamed>"
    AFTER UPDATE ON assettype
    FROM assettype
    NOT DEFERRABLE INITIALLY IMMEDIATE
    FOR EACH ROW
    EXECUTE PROCEDURE "RI_FKey_cascade_upd"('<unnamed>', 'assettype', 'assettype', 'UNSPECIFIED', 'pid', 'id');

   
   I was wondering if I need to worry about the RI_FKey_check_ins statement.

   Will the following take care of all three statements?

   ALTER TABLE ONLY assettype
   ADD CONSTRAINT at_fk_1 FOREIGN KEY (pid) REFERENCES assettype(id) 
   ON UPDATE CASCADE ON DELETE CASCADE;


    Are there any other gottcha's when doing this type of migration?  
(I need to use the FKEY syntax, so a schema visualizer will show the 
foreign key relationships).


   thanks a ton,


   mike




Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group