FOREIGN KEY migration of syntax, help needed

Поиск
Список
Период
Сортировка
От Mike Haberman
Тема FOREIGN KEY migration of syntax, help needed
Дата
Msg-id 20070731191949.GA43615@ncsa.uiuc.edu
обсуждение исходный текст
Ответы Re: FOREIGN KEY migration of syntax, help needed  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: {Spam} FOREIGN KEY migration of syntax, help needed  (Dimitri Fontaine <dfontaine@hi-media.com>)
Список pgsql-general
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


В списке pgsql-general по дате отправления:

Предыдущее
От: Robert Landrum
Дата:
Сообщение: Indexing Hostnames with tsearch2 and fti.c
Следующее
От: RW
Дата:
Сообщение: Re: Need quick help with standalone mode