Index: openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d16-1.0d17.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d16-1.0d17.sql,v diff -u -r1.1 -r1.2 --- openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d16-1.0d17.sql 4 Oct 2005 21:50:45 -0000 1.1 +++ openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d16-1.0d17.sql 2 Feb 2006 23:25:03 -0000 1.2 @@ -1 +1,20 @@ -ALTER TABLE contact_complaint_tracking DROP CONSTRAINT contact_complaint_tracking_supplier_fk; +-- check to see if contact_complaint_tracking exists, if it does then we remove the contact_complaint_tracking_supplier_fk constriant + +create function inline_0() returns integer as ' +declare + v_table_count boolean; +begin + + v_table_count := ''1'' from pg_class where relname = ''contact_complaint_tracking''; + + if v_table_count is true then + ALTER TABLE contact_complaint_tracking DROP CONSTRAINT contact_complaint_tracking_supplier_fk; + end if; + + return 0; + +end;' language 'plpgsql'; + +-- Calling and droping the function +select inline_0(); +drop function inline_0();