]> wagnertech.de Git - kivitendo-erp.git/blob - sql/Pg-upgrade2/shopimages.sql
WebshopApi: ShopImage
[kivitendo-erp.git] / sql / Pg-upgrade2 / shopimages.sql
1 -- @tag:shopimages
2 -- @description: Tabelle für Shopbilder und zusätzliche Konfiguration und valid_type für Filemanagement
3 -- @charset: UTF-8
4 -- @depends: release_3_5_0 files shop_parts
5 -- @ignore: 0
6
7 CREATE TABLE shop_images(
8   id                      SERIAL PRIMARY KEY,
9   file_id                 INTEGER REFERENCES files(id) ON DELETE CASCADE,
10   position                INTEGER,
11   thumbnail_content       BYTEA,
12   thumbnail_width         INTEGER,
13   thumbnail_height        INTEGER,
14   thumbnail_content_type  TEXT,
15   itime                   TIMESTAMP DEFAULT now(),
16   mtime                   TIMESTAMP
17 );
18
19 CREATE TRIGGER mtime_shop_images BEFORE UPDATE ON shop_images FOR EACH ROW EXECUTE PROCEDURE set_mtime();
20
21 ALTER TABLE defaults ADD COLUMN doc_storage_for_shopimages      text default 'Filesystem';
22
23 ALTER TABLE files
24   DROP CONSTRAINT valid_type;
25 ALTER TABLE files
26   ADD  CONSTRAINT valid_type CHECK (
27              (object_type = 'credit_note'     ) OR (object_type = 'invoice'                 ) OR (object_type = 'sales_order'       )
28           OR (object_type = 'sales_quotation' ) OR (object_type = 'sales_delivery_order'    ) OR (object_type = 'request_quotation' )
29           OR (object_type = 'purchase_order'  ) OR (object_type = 'purchase_delivery_order' ) OR (object_type = 'purchase_invoice'  )
30           OR (object_type = 'vendor'          ) OR (object_type = 'customer'                ) OR (object_type = 'part'              )
31           OR (object_type = 'gl_transaction'  ) OR (object_type = 'dunning'                 ) OR (object_type = 'dunning1'          )
32           OR (object_type = 'dunning2'        ) OR (object_type = 'dunning3'                ) OR (object_type = 'draft'             )
33           OR (object_type = 'statement'       ) OR (object_type = 'shop_image'              )
34   );