epic-s6ts
[kivitendo-erp.git] / sql / Pg-upgrade2 / requirement_specs_section_templates.sql
1 -- @tag: requirement_specs_section_templates
2 -- @description: requirement_specs_section_templates
3 -- @depends: release_3_0_0 requirement_specs
4
5 ALTER TABLE requirement_specs ALTER COLUMN type_id     DROP NOT NULL;
6 ALTER TABLE requirement_specs ALTER COLUMN status_id   DROP NOT NULL;
7 ALTER TABLE requirement_specs ALTER COLUMN customer_id DROP NOT NULL;
8
9 ALTER TABLE requirement_specs
10 ADD CONSTRAINT requirement_specs_is_template_or_has_customer_status_type
11 CHECK (
12     is_template
13  OR (    (type_id     IS NOT NULL)
14      AND (status_id   IS NOT NULL)
15      AND (customer_id IS NOT NULL))
16 );