Index: openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d3-1.0d4.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d3-1.0d4.sql,v
diff -u -r1.1 -r1.2
--- openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d3-1.0d4.sql	6 Jul 2005 23:59:26 -0000	1.1
+++ openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d3-1.0d4.sql	7 Jul 2005 18:52:38 -0000	1.2
@@ -6,6 +6,8 @@
 --
 --
 
+alter table contact_rels drop column comment; 
+alter table contact_rels drop column comment_format;
 
 -- create contact application groups
 
@@ -14,10 +16,11 @@
 declare
   package                  record;
   member                   record;
+  delete                   record;
 begin
 
   FOR package IN select application_group__new (
-                 acs_object_id_seq.nextval,
+                 acs_object_id_seq.nextval::integer,
                  ''application_group'',
                  now(),
                  NULL,
@@ -29,17 +32,40 @@
                  package_id
                  ) as new_group_id, package_id from apm_packages where package_key = ''contacts''
   LOOP
-      FOR member IN select distinct member_id from group_member_map where group_id = ''-2''
-      LOOP
-      END LOOP;
 
+        RAISE NOTICE ''NEW GROUP ID IS %'', package.new_group_id;
+        FOR member IN select distinct member_id, acs_object__name(member_id) as name from group_member_map where group_id = ''-2''
+        LOOP
 
+              PERFORM membership_rel__new(
+                    NULL,
+                    ''contact_rel'',
+                    package.new_group_id,
+                    member.member_id,
+                    ''approved'',
+                    NULL,
+                    NULL
+              );
+              RAISE NOTICE ''NEW USER IS % (%)'', member.name, member.member_id;
+
+        END LOOP;
+
   END LOOP;
 
+  FOR delete IN select rel_id, member_id, acs_object__name(member_id) as name from group_member_map where group_id = ''-2'' and member_id not in ( select user_id from users )
+  LOOP
+
+        PERFORM acs_rel__delete(delete.rel_id);
+        RAISE NOTICE ''DELETE USER IS % (%)'', delete.name, delete.member_id;
+    
+  END LOOP;
+
+
   return ''1'';
   
 end;' language 'plpgsql' stable strict;
-
+select contacts_upgrade_1d3_to_1d4();
 drop function contacts_upgrade_1d3_to_1d4();
 
 -- create new relations
+        
