Spaltentyp "custom_variable_configs.type" und ".module" auf TEXT geändert
[kivitendo-erp.git] / sql / Pg-upgrade2 / custom_variable_configs_column_type_text.sql
1 -- @tag: custom_variable_configs_column_type_text
2 -- @description: Spaltentypen in 'custom_varialbe_configs' anpassen & schärfere Restriktionen
3 -- @depends: release_3_0_0
4 -- @charset: utf-8
5 ALTER TABLE custom_variable_configs ALTER COLUMN type   TYPE TEXT;
6 ALTER TABLE custom_variable_configs ALTER COLUMN module TYPE TEXT;
7
8 UPDATE custom_variable_configs SET searchable          = FALSE WHERE searchable          IS NULL;
9 UPDATE custom_variable_configs SET includeable         = FALSE WHERE includeable         IS NULL;
10 UPDATE custom_variable_configs SET included_by_default = FALSE WHERE included_by_default IS NULL;
11
12 ALTER TABLE custom_variable_configs ALTER COLUMN searchable          SET NOT NULL;
13 ALTER TABLE custom_variable_configs ALTER COLUMN includeable         SET NOT NULL;
14 ALTER TABLE custom_variable_configs ALTER COLUMN included_by_default SET NOT NULL;
15 ALTER TABLE custom_variable_configs ALTER COLUMN name                SET NOT NULL;
16 ALTER TABLE custom_variable_configs ALTER COLUMN description         SET NOT NULL;
17 ALTER TABLE custom_variable_configs ALTER COLUMN type                SET NOT NULL;
18 ALTER TABLE custom_variable_configs ALTER COLUMN module              SET NOT NULL;
19 ALTER TABLE custom_variable_configs ALTER COLUMN sortkey             SET NOT NULL;
20
21 ALTER TABLE custom_variable_configs
22 ADD CONSTRAINT custom_variable_configs_name_description_type_module_not_empty
23 CHECK (    type        <> ''
24        AND module      <> ''
25        AND name        <> ''
26        AND description <> '');
27
28 ALTER TABLE custom_variable_configs
29 ADD CONSTRAINT custom_variable_configs_options_not_empty_for_select
30 CHECK ((type <> 'select') OR (COALESCE(options, '') <> ''));