2 -- @description: Tabelle für Shopbilder und zusätzliche Konfiguration und valid_type für Filemanagement
 
   3 -- @depends: release_3_5_0 files shop_parts
 
   6 CREATE TABLE shop_images(
 
   8   file_id                 INTEGER REFERENCES files(id) ON DELETE CASCADE,
 
  10   thumbnail_content       BYTEA,
 
  11   thumbnail_width         INTEGER,
 
  12   thumbnail_height        INTEGER,
 
  13   thumbnail_content_type  TEXT,
 
  14   itime                   TIMESTAMP DEFAULT now(),
 
  18 CREATE TRIGGER mtime_shop_images BEFORE UPDATE ON shop_images FOR EACH ROW EXECUTE PROCEDURE set_mtime();
 
  20 ALTER TABLE defaults ADD COLUMN doc_storage_for_shopimages      text default 'Filesystem';
 
  23   DROP CONSTRAINT valid_type;
 
  25   ADD  CONSTRAINT valid_type CHECK (
 
  26              (object_type = 'credit_note'     ) OR (object_type = 'invoice'                 ) OR (object_type = 'sales_order'       )
 
  27           OR (object_type = 'sales_quotation' ) OR (object_type = 'sales_delivery_order'    ) OR (object_type = 'request_quotation' )
 
  28           OR (object_type = 'purchase_order'  ) OR (object_type = 'purchase_delivery_order' ) OR (object_type = 'purchase_invoice'  )
 
  29           OR (object_type = 'vendor'          ) OR (object_type = 'customer'                ) OR (object_type = 'part'              )
 
  30           OR (object_type = 'gl_transaction'  ) OR (object_type = 'dunning'                 ) OR (object_type = 'dunning1'          )
 
  31           OR (object_type = 'dunning2'        ) OR (object_type = 'dunning3'                ) OR (object_type = 'draft'             )
 
  32           OR (object_type = 'statement'       ) OR (object_type = 'shop_image'              )