Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql,v
diff -u -r1.32.4.2 -r1.32.4.3
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql	1 Jul 2016 08:57:55 -0000	1.32.4.2
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-relationships-create.sql	31 Aug 2016 18:57:41 -0000	1.32.4.3
@@ -48,6 +48,8 @@
 	max_n_rels_two	integer
 			constraint acs_rel_types_max_n_2_ck
 			check (max_n_rels_two >= 0),
+        composable_p    boolean
+	                default 't' not null,
 	constraint acs_rel_types_n_rels_one_ck
 	check (min_n_rels_one <= max_n_rels_one),
 	constraint acs_rel_types_n_rels_two_ck
@@ -59,7 +61,7 @@
 create index acs_rel_types_objtypetwo_idx on acs_rel_types (object_type_two);
 create index acs_rel_types_role_two_idx on acs_rel_types (role_two);
 
-comment on table acs_rel_types is '
+comment on table acs_rel_types is $$
  Each row in <code>acs_rel_types</code> represents a type of
  relationship between objects. For example, the following DML
  statement:
@@ -69,17 +71,17 @@
    object_type_one, role_one, min_n_rels_one, max_n_rels_one,
    object_type_two, role_two, min_n_rels_two, max_n_rels_two)
  values
-  (''employment'',
-   ''person'', ''employee'', 0, null,
-   ''company'', ''employer'', 0, null)
+  ('employment',
+   'person', 'employee', 0, null,
+   'company', 'employer', 0, null)
  </pre></blockquote>
  defines an "employment" relationship type that can be expressed in
  in natural language as:
  <blockquote>
  A person may be the employee of zero or more companies, and a company
  may be the employer of zero or more people.
  </blockquote>
-';
+$$;
 
 
 
@@ -197,11 +199,39 @@
 -- procedure create_type
 
 
--- added
-select define_function_args('acs_rel_type__create_type','rel_type,pretty_name,pretty_plural,supertype;relationship,table_name,id_column,package_name,object_type_one,role_one;null,min_n_rels_one,max_n_rels_one,object_type_two,role_two;null,min_n_rels_two,max_n_rels_two');
+-- procedure create_type
 
+--  acs_rel_type__create_type /15 vs. /16 has
+--  /15 has no "roles" (one and two), but "type_extension_table"
+
+-- /16
+--   pos 1-7: same as /15
+--   pos 08: object_type_one (varchar) 
+--   pos 09: role_one (varchar) 
+--   pos 10: min_n_rels_one (integer)
+--   pos 11: max_n_rels (integer)
+--   pos 12: object_type_one (varchar) 
+--   pos 13: role_two (varchar) 
+--   pos 14: min_n_rels_two (integer)
+--   pos 15: max_n_rels_two (integer) 
+--   pos 16: composable_p (boolean)
+
+-- /15 
+--   pos 1-7: same as /15
+--   pos 08: type_extension_table (varchar)
+--   pos 09: object_type_one (varchar) 
+--   pos 10: min_n_rels_one (integer)
+--   pos 11: max_n_rels (integer)
+--   pos 12: object_type_two (varchar) 
+--   pos 13: min_n_rels_two (integer)
+--   pos 14: max_n_rels_two (integer) 
+--   pos 15: composable_p (boolean)
+
+
+select define_function_args('acs_rel_type__create_type','rel_type,pretty_name,pretty_plural,supertype;relationship,table_name,id_column,package_name,object_type_one,role_one;null,min_n_rels_one,max_n_rels_one,object_type_two,role_two;null,min_n_rels_two,max_n_rels_two,composable_p;t');
+
 --
--- procedure acs_rel_type__create_type/15
+-- procedure acs_rel_type__create_type/16
 --
 CREATE OR REPLACE FUNCTION acs_rel_type__create_type(
    create_type__rel_type varchar,
@@ -218,7 +248,8 @@
    create_type__object_type_two varchar,
    create_type__role_two varchar,  -- default null
    create_type__min_n_rels_two integer,
-   create_type__max_n_rels_two integer
+   create_type__max_n_rels_two integer,
+   create_type__composable_p boolean default true
 
 ) RETURNS integer AS $$
 DECLARE
@@ -245,25 +276,26 @@
       object_type_one, role_one,
       min_n_rels_one, max_n_rels_one,
       object_type_two, role_two,
-      min_n_rels_two, max_n_rels_two)
+      min_n_rels_two, max_n_rels_two,
+      composable_p)
     values
      (create_type__rel_type,
       create_type__object_type_one, create_type__role_one,
       create_type__min_n_rels_one, create_type__max_n_rels_one,
       create_type__object_type_two, create_type__role_two,
-      create_type__min_n_rels_two, create_type__max_n_rels_two);
+      create_type__min_n_rels_two, create_type__max_n_rels_two,
+      create_type__composable_p);
 
     return 0; 
 END;
 $$ LANGUAGE plpgsql;
 
 
 
--- procedure create_type
 
 
 --
--- procedure acs_rel_type__create_type/14
+-- procedure acs_rel_type__create_type/15
 --
 CREATE OR REPLACE FUNCTION acs_rel_type__create_type(
    create_type__rel_type varchar,
@@ -279,7 +311,8 @@
    create_type__max_n_rels_one integer,
    create_type__object_type_two varchar,
    create_type__min_n_rels_two integer,
-   create_type__max_n_rels_two integer
+   create_type__max_n_rels_two integer,
+   create_type__composable_p boolean default true
 
 ) RETURNS integer AS $$
 DECLARE
@@ -308,13 +341,15 @@
       object_type_one, role_one,
       min_n_rels_one, max_n_rels_one,
       object_type_two, role_two,
-      min_n_rels_two, max_n_rels_two)
+      min_n_rels_two, max_n_rels_two,
+      composable_p)
     values
      (create_type__rel_type,
       create_type__object_type_one, create_type__role_one,
       create_type__min_n_rels_one, create_type__max_n_rels_one,
       create_type__object_type_two, create_type__role_two,
-      create_type__min_n_rels_two, create_type__max_n_rels_two);
+      create_type__min_n_rels_two, create_type__max_n_rels_two,
+      create_type__composable_p);
 
     return 0; 
 END;
@@ -522,9 +557,10 @@
 END;
 $$ LANGUAGE plpgsql;
 
-create trigger acs_rels_in_tr before insert or update on acs_rels
-for each row execute procedure acs_rels_in_tr ();
 
+ create trigger acs_rels_in_tr before insert or update on acs_rels
+ for each row execute procedure acs_rels_in_tr ();
+
 -- show errors
 
 
