Index: openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql,v diff -u -r1.4 -r1.4.2.1 --- openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 4 Jun 2006 00:45:38 -0000 1.4 +++ openacs-4/packages/acs-kernel/sql/postgresql/upgrade/upgrade-5.2.0d1-5.2.0d2.sql 14 Dec 2006 03:42:54 -0000 1.4.2.1 @@ -1,3 +1,20 @@ +-- procedure merge +create or replace function membership_rel__merge (integer) +returns integer as ' +declare + merge__rel_id alias for $1; +begin + update membership_rels + set member_state = ''merged'' + where rel_id = merge__rel_id; + + return 0; +end;' language 'plpgsql'; + + +alter table membership_rels drop constraint membership_rel_mem_ck; + +alter table membership_rels add constraint membership_rel_mem_ck check (member_state in ('approved','needs approval','banned','rejected','deleted','merged')); create function inline_0 () returns integer as ' declare @@ -442,7 +459,9 @@ register_parameter__max_n_values alias for $9; -- default 1 v_parameter_id apm_parameters.parameter_id%TYPE; - cur_val record; + v_value_id apm_parameter_values.value_id%TYPE; + v_pkg record; + begin -- Create the new parameter. v_parameter_id := acs_object__new( @@ -453,7 +472,7 @@ null, null, ''t'', - register_parameter__package_key || '': Parameter '' || register_parameter__parameter_name, + register_parameter__package_key || '' - '' || register_parameter__parameter_name, null ); @@ -468,24 +487,52 @@ register_parameter__max_n_values); -- Propagate parameter to new instances. - for cur_val in select ap.package_id, p.parameter_id, p.default_value - from apm_parameters p left outer join apm_parameter_values v - using (parameter_id), apm_packages ap - where p.package_key = ap.package_key - and v.attr_value is null - and p.package_key = register_parameter__package_key + for v_pkg in + select package_id + from apm_packages + where package_key = register_parameter__package_key loop - PERFORM apm__set_value( - cur_val.parameter_id, - cur_val.package_id, - cur_val.default_value + v_value_id := apm_parameter_value__new( + null, + v_pkg.package_id, + v_parameter_id, + register_parameter__default_value ); - end loop; + end loop; return v_parameter_id; end;' language 'plpgsql'; + +create or replace function apm__register_package (varchar,varchar,varchar,varchar,varchar,boolean,boolean,varchar,integer) +returns integer as ' +declare + package_key alias for $1; + pretty_name alias for $2; + pretty_plural alias for $3; + package_uri alias for $4; + package_type alias for $5; + initial_install_p alias for $6; -- default ''f'' + singleton_p alias for $7; -- default ''f'' + spec_file_path alias for $8; -- default null + spec_file_mtime alias for $9; -- default null +begin + PERFORM apm_package_type__create_type( + package_key, + pretty_name, + pretty_plural, + package_uri, + package_type, + initial_install_p, + singleton_p, + spec_file_path, + spec_file_mtime + ); + + return 0; +end;' language 'plpgsql'; + drop function apm__update_parameter (integer,varchar,varchar,varchar,varchar,varchar,integer,integer); create or replace function apm__update_parameter (integer,varchar,varchar,varchar,varchar,varchar,integer,integer)