Index: openacs-4/packages/acs-content-repository/sql/postgresql/content-type.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-content-repository/sql/postgresql/content-type.sql,v
diff -u -N -r1.54 -r1.55
--- openacs-4/packages/acs-content-repository/sql/postgresql/content-type.sql	27 Jan 2010 17:34:09 -0000	1.54
+++ openacs-4/packages/acs-content-repository/sql/postgresql/content-type.sql	20 Feb 2011 00:34:00 -0000	1.55
@@ -68,21 +68,10 @@
     end if;
   end if;
 
- -- create the attribute table if not already created
-
-  select count(*) > 0 into v_temp_p 
+  select count(*) = 0 into v_temp_p 
     from pg_class
    where relname = lower(create_type__table_name);
 
-  if NOT v_temp_p and create_type__table_name is not null then
-    select table_name into v_supertype_table from acs_object_types
-      where object_type = create_type__supertype;
-
-    execute ''create table '' || create_type__table_name || '' ('' ||
-      create_type__id_column || '' integer constraint '' || create_type__table_name || ''_pk primary key '' || 
-      '' constraint '' || create_type__table_name || ''_fk references '' || v_supertype_table || '')'';
-  end if;
-
   PERFORM acs_object_type__create_type (
     create_type__content_type,
     create_type__pretty_name,
@@ -93,7 +82,9 @@
     null,
     ''f'',
     null,
-    create_type__name_method
+    create_type__name_method,
+    v_temp_p,
+    ''f''
   );
 
   PERFORM content_type__refresh_view(create_type__content_type);
@@ -324,8 +315,6 @@
   return 0; 
 end;' language 'plpgsql';
 
-
-
 select define_function_args('content_type__create_attribute','content_type,attribute_name,datatype,pretty_name,pretty_plural,sort_order,default_value,column_spec;text');
 
 create or replace function content_type__create_attribute (varchar,varchar,varchar,varchar,varchar,integer,varchar,varchar)
@@ -359,12 +348,6 @@
     and c.oid = a.attrelid
     and a.attname = lower(create_attribute__attribute_name);
 
- if NOT v_column_exists then
-   execute ''alter table '' || v_table_name || '' add '' || 
-      create_attribute__attribute_name || '' '' 
-      || create_attribute__column_spec;
- end if;
-
  v_attr_id := acs_attribute__create_attribute (
    create_attribute__content_type,
    create_attribute__attribute_name,
@@ -378,7 +361,14 @@
    1,
    create_attribute__sort_order,
    ''type_specific'',
-   ''f''
+   ''f'',
+   not v_column_exists,
+   null,
+   null,
+   null,
+   null,
+   null,
+   create_attribute__column_spec
  );
 
  PERFORM content_type__refresh_view(create_attribute__content_type);
@@ -387,7 +377,6 @@
 
 end;' language 'plpgsql';
 
-
 select define_function_args('content_type__drop_attribute','content_type,attribute_name,drop_column;f');
 
 create or replace function content_type__drop_attribute (varchar,varchar,boolean)
