Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql,v diff -u -r1.23 -r1.24 --- openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql 4 Jun 2006 00:45:38 -0000 1.23 +++ openacs-4/packages/acs-kernel/sql/postgresql/acs-metadata-create.sql 24 Sep 2006 11:45:08 -0000 1.24 @@ -574,9 +574,18 @@ drop_type__object_type alias for $1; drop_type__cascade_p alias for $2; -- default ''f'' row record; + object_row record; begin - -- XXX: drop_type cascade_p is ignored (ignored in oracle too, but defaults f) + if drop_type__cascade_p then + for object_row in select object_id + from acs_objects + where object_type = drop_type__object_type + loop + PERFORM acs_object__delete (object_row.object_id); + end loop; + end if; + -- drop all the attributes associated with this type for row in select attribute_name from acs_attributes Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.3.0d1-5.3.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.3.0d1-5.3.0d2.sql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.3.0d1-5.3.0d2.sql 24 Sep 2006 09:26:36 -0000 1.2 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.3.0d1-5.3.0d2.sql 24 Sep 2006 11:45:09 -0000 1.3 @@ -38,3 +38,41 @@ return 0; end;' language 'plpgsql'; + +-- procedure drop_type +create or replace function acs_object_type__drop_type (varchar,boolean) +returns integer as ' +declare + drop_type__object_type alias for $1; + drop_type__cascade_p alias for $2; -- default ''f'' + row record; + object_row record; +begin + + if drop_type__cascade_p then + for object_row in select object_id + from acs_objects + where object_type = drop_type__object_type + loop + PERFORM acs_object__delete (object_row.object_id); + end loop; + end if; + + -- drop all the attributes associated with this type + for row in select attribute_name + from acs_attributes + where object_type = drop_type__object_type + loop + PERFORM acs_attribute__drop_attribute (drop_type__object_type, + row.attribute_name); + end loop; + + delete from acs_attributes + where object_type = drop_type__object_type; + + delete from acs_object_types + where object_type = drop_type__object_type; + + return 0; +end;' language 'plpgsql'; +