Merge branch 'b-3.6.1' of ../kivitendo-erp_20220811
[kivitendo-erp.git] / sql / Pg-upgrade2 / part_classifications.sql
1 -- @tag: part_classifications
2 -- @description: "zusätzliche Tabelle mit Flags zur Klassifizierung von Artikeln"
3 -- @depends: release_3_4_1
4 CREATE TABLE part_classifications (
5     id SERIAL PRIMARY KEY,
6     description text,
7     abbreviation text,
8     used_for_purchase BOOLEAN DEFAULT 't' NOT NULL,
9     used_for_sale     BOOLEAN DEFAULT 't' NOT NULL
10 );
11
12 INSERT INTO part_classifications values(0,'-------'    ,'None (typeabbreviation)','t','t');
13 INSERT INTO part_classifications values(1,'Purchase'   ,'Purchase (typeabbreviation)'   ,'t','f');
14 INSERT INTO part_classifications values(2,'Sales'      ,'Sales (typeabbreviation)'      ,'f','t');
15 INSERT INTO part_classifications values(3,'Merchandise','Merchandise (typeabbreviation)','t','t');
16 INSERT INTO part_classifications values(4,'Production' ,'Production (typeabbreviation)' ,'f','t');
17 SELECT setval('part_classifications_id_seq',4);
18 ALTER TABLE parts ADD COLUMN classification_id integer DEFAULT 0;
19 ALTER TABLE parts ADD CONSTRAINT part_classification_id_fkey FOREIGN KEY (classification_id) REFERENCES part_classifications(id);