adding "deleted" functionality to CNs
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Mar 2006 18:14:42 +0000 (18:14 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 17 Mar 2006 18:14:42 +0000 (18:14 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3392 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm
Open-ILS/src/sql/Pg/040.schema.asset.sql

index ca1dbd2..46e629c 100644 (file)
@@ -19,7 +19,7 @@ use base qw/asset/;
 __PACKAGE__->table( 'asset_call_number' );
 __PACKAGE__->columns( Primary => qw/id/ );
 __PACKAGE__->columns( Essential => qw/record label creator create_date editor
-                                  edit_date record label owning_lib/ );
+                                  edit_date record label owning_lib deleted/ );
 
 #-------------------------------------------------------------------------------
 package asset::call_number_note;
index e8454ca..271c5f0 100644 (file)
@@ -121,6 +121,7 @@ CREATE TABLE asset.call_number (
        record          bigint                          NOT NULL,
        owning_lib      INT                             NOT NULL,
        label           TEXT                            NOT NULL,
+       deleted         BOOL                            NOT NULL DEFAULT FALSE,
        CONSTRAINT asset_call_number_label_once_per_lib UNIQUE (record, owning_lib, label)
 );
 CREATE INDEX asset_call_number_record_idx ON asset.call_number (record);
@@ -128,6 +129,7 @@ CREATE INDEX asset_call_number_creator_idx ON asset.call_number (creator);
 CREATE INDEX asset_call_number_editor_idx ON asset.call_number (editor);
 CREATE INDEX asset_call_number_dewey_idx ON asset.call_number (public.call_number_dewey(label));
 CREATE INDEX asset_call_number_upper_label_id_owning_lib_idx ON asset.call_number (upper(label),id,owning_lib);
+CREATE RULE protect_cn_delete AS ON DELETE TO asset.call_number DO INSTEAD UPDATE asset.call_number SET deleted = TRUE WHERE OLD.id = asset.call_number.id;
 
 INSERT INTO asset.call_number VALUES (-1,1,NOW(),1,NOW(),-1,1,'UNCATALOGED');