</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>
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;
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