7d509ad61b4390f91fec0bf6d9c728b6eb14656f
[kivitendo-erp.git] / sql / Pg-upgrade2 / shop_parts.sql
1 -- @tag: shop_parts
2 -- @description: Add tables for part information for shop
3 -- @depends: release_3_5_0 shops
4 -- @ignore: 0
5
6 CREATE TABLE shop_parts (
7   id               SERIAL PRIMARY KEY,
8   shop_id          INTEGER NOT NULL REFERENCES shops(id),
9   part_id          INTEGER NOT NULL REFERENCES parts(id),
10   shop_description TEXT,
11   itime            TIMESTAMP DEFAULT now(),
12   mtime            TIMESTAMP,
13   last_update      TIMESTAMP,
14   show_date        DATE,   -- the starting date for displaying part in shop
15   sortorder        INTEGER,
16   front_page       BOOLEAN NOT NULL DEFAULT false,
17   active           BOOLEAN NOT NULL DEFAULT false,  -- rather than obsolete
18   shop_category TEXT[][],
19   active_price_source TEXT,
20   metatag_keywords TEXT,
21   metatag_description TEXT,
22   metatag_title TEXT,
23   UNIQUE (part_id, shop_id)  -- make sure a shop_part appears only once per shop and part
24 );
25
26 CREATE TRIGGER mtime_shop_parts BEFORE UPDATE ON shop_parts
27     FOR EACH ROW EXECUTE PROCEDURE set_mtime();