From ab56c1a046909c2d193c65335c34cc11b0630a46 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 24 May 2013 14:33:56 +0200 Subject: [PATCH] =?utf8?q?Spaltentyp=20"custom=5Fvariable=5Fconfigs.type"?= =?utf8?q?=20und=20".module"=20auf=20TEXT=20ge=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/MetaSetup/CustomVariableConfig.pm | 16 +++++----- ...stom_variable_configs_column_type_text.sql | 30 +++++++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql diff --git a/SL/DB/MetaSetup/CustomVariableConfig.pm b/SL/DB/MetaSetup/CustomVariableConfig.pm index 5ee01c19d..c4077f805 100644 --- a/SL/DB/MetaSetup/CustomVariableConfig.pm +++ b/SL/DB/MetaSetup/CustomVariableConfig.pm @@ -11,16 +11,16 @@ __PACKAGE__->meta->setup( columns => [ id => { type => 'integer', not_null => 1, sequence => 'custom_variable_configs_id' }, - name => { type => 'text' }, - description => { type => 'text' }, - type => { type => 'varchar', length => 20 }, - module => { type => 'varchar', length => 20 }, + name => { type => 'text', not_null => 1 }, + description => { type => 'text', not_null => 1 }, + type => { type => 'text', not_null => 1 }, + module => { type => 'text', not_null => 1 }, default_value => { type => 'text' }, options => { type => 'text' }, - searchable => { type => 'boolean' }, - includeable => { type => 'boolean' }, - included_by_default => { type => 'boolean' }, - sortkey => { type => 'integer' }, + searchable => { type => 'boolean', not_null => 1 }, + includeable => { type => 'boolean', not_null => 1 }, + included_by_default => { type => 'boolean', not_null => 1 }, + sortkey => { type => 'integer', not_null => 1 }, itime => { type => 'timestamp', default => 'now()' }, mtime => { type => 'timestamp' }, flags => { type => 'text' }, diff --git a/sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql b/sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql new file mode 100644 index 000000000..98ebbbc05 --- /dev/null +++ b/sql/Pg-upgrade2/custom_variable_configs_column_type_text.sql @@ -0,0 +1,30 @@ +-- @tag: custom_variable_configs_column_type_text +-- @description: Spaltentypen in 'custom_varialbe_configs' anpassen & schärfere Restriktionen +-- @depends: release_3_0_0 +-- @charset: utf-8 +ALTER TABLE custom_variable_configs ALTER COLUMN type TYPE TEXT; +ALTER TABLE custom_variable_configs ALTER COLUMN module TYPE TEXT; + +UPDATE custom_variable_configs SET searchable = FALSE WHERE searchable IS NULL; +UPDATE custom_variable_configs SET includeable = FALSE WHERE includeable IS NULL; +UPDATE custom_variable_configs SET included_by_default = FALSE WHERE included_by_default IS NULL; + +ALTER TABLE custom_variable_configs ALTER COLUMN searchable SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN includeable SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN included_by_default SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN name SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN description SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN type SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN module SET NOT NULL; +ALTER TABLE custom_variable_configs ALTER COLUMN sortkey SET NOT NULL; + +ALTER TABLE custom_variable_configs +ADD CONSTRAINT custom_variable_configs_name_description_type_module_not_empty +CHECK ( type <> '' + AND module <> '' + AND name <> '' + AND description <> ''); + +ALTER TABLE custom_variable_configs +ADD CONSTRAINT custom_variable_configs_options_not_empty_for_select +CHECK ((type <> 'select') OR (COALESCE(options, '') <> '')); -- 2.20.1