allow multiple parts per copy primarily for part per record per copy
authorMike Rylander <mrylander@gmail.com>
Fri, 18 Feb 2011 13:49:18 +0000 (08:49 -0500)
committerMike Rylander <mrylander@gmail.com>
Fri, 18 Feb 2011 13:49:18 +0000 (08:49 -0500)
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/CDBI/asset.pm
Open-ILS/src/sql/Pg/040.schema.asset.sql

index 7f659bb..965db28 100644 (file)
@@ -1955,7 +1955,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
         </permacrud>
        </class>
        <class id="acpm" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="asset::copy_part_map" oils_persist:tablename="asset.copy_part_map" reporter:label="Copy Monograph Part Map">
-               <fields oils_persist:primary="target_copy">
+               <fields oils_persist:primary="id" oils_persist:sequence="asset.copy_part_id_seq">
+                       <field name="id" reporter:datatype="id" />
                        <field name="target_copy" reporter:datatype="link" />
                        <field name="part" reporter:datatype="link"/>
                </fields>
index e69e101..3df4d40 100644 (file)
@@ -63,8 +63,8 @@ package asset::copy_part_map;
 use base qw/asset/;
 
 __PACKAGE__->table( 'asset_copy_part_map' );
-__PACKAGE__->columns( Primary => qw/target_copy/ );
-__PACKAGE__->columns( Essential => qw/part/);
+__PACKAGE__->columns( Primary => qw/id/ );
+__PACKAGE__->columns( Essential => qw/target_copy part/);
 
 #-------------------------------------------------------------------------------
 package asset::stat_cat;
index d203ef7..64bf2a2 100644 (file)
@@ -92,9 +92,11 @@ CREATE INDEX cp_create_date  ON asset.copy (create_date);
 CREATE RULE protect_copy_delete AS ON DELETE TO asset.copy DO INSTEAD UPDATE asset.copy SET deleted = TRUE WHERE OLD.id = asset.copy.id;
 
 CREATE TABLE asset.copy_part_map (
-    target_copy BIGINT  PRIMARY KEY, -- points o asset.copy
+    id          SERIAL  PRIMARY KEY,
+    target_copy BIGINT  NOT NULL, -- points o asset.copy
     part        INT     NOT NULL REFERENCES biblio.monograph_part (id) ON DELETE CASCADE
 );
+CREATE UNIQUE INDEX copy_part_map_cp_part_idx ON asset.copy_part_map (target_copy, part);
 
 CREATE TABLE asset.opac_visible_copies (
   id        BIGINT primary key, -- copy id