This is an automated email from the ASF dual-hosted git repository. pradeep pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/master by this push: new 0ac7c0c RANGER-2802: Java patch J10034 may fail in upgrade case 0ac7c0c is described below commit 0ac7c0c438e85f3b0b83b28efc99ce8221d21d1e Author: pradeep <prad...@apache.org> AuthorDate: Tue Apr 28 19:23:54 2020 +0530 RANGER-2802: Java patch J10034 may fail in upgrade case --- .../optimized/current/ranger_core_db_mysql.sql | 1 + .../db/mysql/patches/047-sortorder-column-size.sql | 44 ++++++++++++ .../optimized/current/ranger_core_db_oracle.sql | 2 + .../patches/043-add-tag-change-log-table.sql | 3 - ...6-insert-statename-in-x-ranger-global-state.sql | 7 +- .../oracle/patches/047-sortorder-column-size.sql | 44 ++++++++++++ .../optimized/current/ranger_core_db_postgres.sql | 1 + .../patches/043-add-tag-change-log-table.sql | 5 -- .../postgres/patches/047-sortorder-column-size.sql | 44 ++++++++++++ .../current/ranger_core_db_sqlanywhere.sql | 2 + .../patches/047-sortorder-column-size.sql | 54 ++++++++++++++ .../optimized/current/ranger_core_db_sqlserver.sql | 1 + .../patches/047-sortorder-column-size.sql | 82 ++++++++++++++++++++++ 13 files changed, 279 insertions(+), 11 deletions(-) diff --git a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql index f39b299..320ab6d 100644 --- a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql +++ b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql @@ -1675,6 +1675,7 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('044',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('045',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('046',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y'); +INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y'); INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) diff --git a/security-admin/db/mysql/patches/047-sortorder-column-size.sql b/security-admin/db/mysql/patches/047-sortorder-column-size.sql new file mode 100644 index 0000000..5845f0d --- /dev/null +++ b/security-admin/db/mysql/patches/047-sortorder-column-size.sql @@ -0,0 +1,44 @@ +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +drop procedure if exists modify_column_sort_order_to_int; + +delimiter ;; +create procedure modify_column_sort_order_to_int(IN tableName varchar(64)) begin + if exists (select * from information_schema.columns where table_schema=database() and table_name = tableName and column_name = 'sort_order' and data_type='tinyint') then + SET @query = CONCAT('ALTER TABLE `', tableName,'` MODIFY COLUMN `sort_order` INT DEFAULT 0'); + PREPARE stmt FROM @query; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; + end if; +end;; + +delimiter ; + +call modify_column_sort_order_to_int('x_service_config_def'); +call modify_column_sort_order_to_int('x_resource_def'); +call modify_column_sort_order_to_int('x_access_type_def'); +call modify_column_sort_order_to_int('x_policy_condition_def'); +call modify_column_sort_order_to_int('x_context_enricher_def'); +call modify_column_sort_order_to_int('x_enum_element_def'); +call modify_column_sort_order_to_int('x_policy_resource_map'); +call modify_column_sort_order_to_int('x_policy_item'); +call modify_column_sort_order_to_int('x_policy_item_access'); +call modify_column_sort_order_to_int('x_policy_item_condition'); +call modify_column_sort_order_to_int('x_policy_item_user_perm'); +call modify_column_sort_order_to_int('x_policy_item_group_perm'); +call modify_column_sort_order_to_int('x_datamask_type_def'); + +drop procedure if exists modify_column_sort_order_to_int; diff --git a/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql b/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql index 67877a5..fbf91d8 100644 --- a/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql +++ b/security-admin/db/oracle/optimized/current/ranger_core_db_oracle.sql @@ -1871,7 +1871,9 @@ INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,act INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '044',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y'); INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '045',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y'); INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '046',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y'); +INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, '047',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y'); INSERT INTO x_db_version_h (id,version,inst_at,inst_by,updated_at,updated_by,active) VALUES (X_DB_VERSION_H_SEQ.nextval, 'DB_PATCHES',sys_extract_utc(systimestamp),'Ranger 1.0.0',sys_extract_utc(systimestamp),'localhost','Y'); + INSERT INTO x_user_module_perm (id,user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (X_USER_MODULE_PERM_SEQ.nextval,getXportalUIdByLoginId('admin'),getModulesIdByName('Reports'),sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),1); INSERT INTO x_user_module_perm (id,user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (X_USER_MODULE_PERM_SEQ.nextval,getXportalUIdByLoginId('admin'),getModulesIdByName('Resource Based Policies'),sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),1); INSERT INTO x_user_module_perm (id,user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (X_USER_MODULE_PERM_SEQ.nextval,getXportalUIdByLoginId('admin'),getModulesIdByName('Audit'),sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),1); diff --git a/security-admin/db/oracle/patches/043-add-tag-change-log-table.sql b/security-admin/db/oracle/patches/043-add-tag-change-log-table.sql index 691cbdb..8195880 100644 --- a/security-admin/db/oracle/patches/043-add-tag-change-log-table.sql +++ b/security-admin/db/oracle/patches/043-add-tag-change-log-table.sql @@ -52,9 +52,6 @@ primary key (id) ); CREATE INDEX x_tag_chng_log_IDX_service_id ON x_tag_change_log(service_id); CREATE INDEX x_tag_chng_log_IDX_tag_ver ON x_tag_change_log(service_tags_version); -COMMIT; -GRANT ALL ON x_tag_change_log TO rangeradmin; -GRANT ALL ON X_TAG_CHANGE_LOG_SEQ TO rangeradmin; COMMIT; diff --git a/security-admin/db/oracle/patches/046-insert-statename-in-x-ranger-global-state.sql b/security-admin/db/oracle/patches/046-insert-statename-in-x-ranger-global-state.sql index 8359f77..89c781d 100644 --- a/security-admin/db/oracle/patches/046-insert-statename-in-x-ranger-global-state.sql +++ b/security-admin/db/oracle/patches/046-insert-statename-in-x-ranger-global-state.sql @@ -19,6 +19,7 @@ DECLARE v_count_1 number:=0; v_count_2 number:=0; v_count_3 number:=0; + sql_stmt VARCHAR(1024); state_name_1 varchar(255):='RangerRole'; state_name_2 varchar(255):='RangerUserStore'; state_name_3 varchar(255):='RangerSecurityZone'; @@ -28,21 +29,21 @@ BEGIN select count(*) into t_count from user_tables where table_name = 'x_ranger_global_state'; if (t_count > 0) then - select count(*) into v_count_1 from x_ranger_global_state where state_name='RangerRole' + select count(*) into v_count_1 from x_ranger_global_state where state_name='RangerRole'; if (v_count_1 = 0) then sql_stmt := 'INSERT INTO x_ranger_global_state (id,create_time,update_time,added_by_id,upd_by_id,version,state_name,app_data) VALUES (X_RANGER_GLOBAL_STATE_SEQ.nextval,sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),:1,:2,1,:3,:4)'; EXECUTE IMMEDIATE sql_stmt USING x_portal_user_id,x_portal_user_id,state_name_1,app_data_1; commit; end if; - select count(*) into v_count_2 from x_ranger_global_state where state_name='RangerUserStore' + select count(*) into v_count_2 from x_ranger_global_state where state_name='RangerUserStore'; if (v_count_2 = 0) then sql_stmt := 'INSERT INTO x_ranger_global_state (id,create_time,update_time,added_by_id,upd_by_id,version,state_name,app_data) VALUES (X_RANGER_GLOBAL_STATE_SEQ.nextval,sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),:1,:2,1,:3,:4)'; EXECUTE IMMEDIATE sql_stmt USING x_portal_user_id,x_portal_user_id,state_name_2,app_data_1; commit; end if; - select count(*) into v_count_3 from x_ranger_global_state where state_name='RangerSecurityZone' + select count(*) into v_count_3 from x_ranger_global_state where state_name='RangerSecurityZone'; if (v_count_3 = 0) then sql_stmt := 'INSERT INTO x_ranger_global_state (id,create_time,update_time,added_by_id,upd_by_id,version,state_name,app_data) VALUES (X_RANGER_GLOBAL_STATE_SEQ.nextval,sys_extract_utc(systimestamp),sys_extract_utc(systimestamp),:1,:2,1,:3,:4)'; EXECUTE IMMEDIATE sql_stmt USING x_portal_user_id,x_portal_user_id,state_name_3,app_data_1; diff --git a/security-admin/db/oracle/patches/047-sortorder-column-size.sql b/security-admin/db/oracle/patches/047-sortorder-column-size.sql new file mode 100644 index 0000000..1509f63 --- /dev/null +++ b/security-admin/db/oracle/patches/047-sortorder-column-size.sql @@ -0,0 +1,44 @@ +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +CREATE OR REPLACE PROCEDURE spmodifysortordercolumn(TableName IN varchar2) +IS + v_column_exists number := 0; +BEGIN + Select count(*) into v_column_exists + from user_tab_cols + where (column_name = upper('sort_order')) + and table_name = upper(TableName) and DATA_TYPE='NUMBER' and DATA_PRECISION=3; + + if (v_column_exists > 0) then + execute immediate 'ALTER TABLE ' || TableName || ' MODIFY(sort_order NUMBER(10) DEFAULT 0)'; + commit; + end if; +END;/ +/ + +call spmodifysortordercolumn('x_service_config_def'); +call spmodifysortordercolumn('x_resource_def'); +call spmodifysortordercolumn('x_access_type_def'); +call spmodifysortordercolumn('x_policy_condition_def'); +call spmodifysortordercolumn('x_context_enricher_def'); +call spmodifysortordercolumn('x_enum_element_def'); +call spmodifysortordercolumn('x_policy_resource_map'); +call spmodifysortordercolumn('x_policy_item'); +call spmodifysortordercolumn('x_policy_item_access'); +call spmodifysortordercolumn('x_policy_item_condition'); +call spmodifysortordercolumn('x_policy_item_user_perm'); +call spmodifysortordercolumn('x_policy_item_group_perm'); +call spmodifysortordercolumn('x_datamask_type_def'); diff --git a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql index e596941..74c7ffc 100644 --- a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql +++ b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql @@ -1798,6 +1798,7 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('044',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('045',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('046',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y'); +INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',current_timestamp,'Ranger 1.0.0',current_timestamp,'localhost','Y'); INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES diff --git a/security-admin/db/postgres/patches/043-add-tag-change-log-table.sql b/security-admin/db/postgres/patches/043-add-tag-change-log-table.sql index 3e060d7..0e4be27 100644 --- a/security-admin/db/postgres/patches/043-add-tag-change-log-table.sql +++ b/security-admin/db/postgres/patches/043-add-tag-change-log-table.sql @@ -32,8 +32,3 @@ commit; CREATE INDEX x_tag_change_log_IDX_service_id ON x_tag_change_log(service_id); CREATE INDEX x_tag_change_log_IDX_tag_version ON x_tag_change_log(service_tags_version); commit; - --- grant all privileges on x_tag_change_log to rangeradmin; --- grant all privileges on x_tag_change_log_seq to rangeradmin; - --- commit; diff --git a/security-admin/db/postgres/patches/047-sortorder-column-size.sql b/security-admin/db/postgres/patches/047-sortorder-column-size.sql new file mode 100644 index 0000000..dd1da4c --- /dev/null +++ b/security-admin/db/postgres/patches/047-sortorder-column-size.sql @@ -0,0 +1,44 @@ +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +select 'delimiter start'; +CREATE OR REPLACE FUNCTION alter_column_sort_order_to_int(tableName varchar(64)) +RETURNS void AS $$ +declare + v_column_exists integer := 0; + query varchar(4000); +begin + select count(*) into v_column_exists from pg_attribute where attrelid in(select oid from pg_class where relname=tableName) and attname='sort_order' and attlen=2; + IF v_column_exists = 1 THEN + query := 'ALTER TABLE ' || tableName || ' ALTER COLUMN sort_order TYPE INT'; + execute query; + END IF; +END; +$$ LANGUAGE plpgsql; +select 'delimiter end'; + +select alter_column_sort_order_to_int('x_service_config_def'); +select alter_column_sort_order_to_int('x_resource_def'); +select alter_column_sort_order_to_int('x_access_type_def'); +select alter_column_sort_order_to_int('x_policy_condition_def'); +select alter_column_sort_order_to_int('x_context_enricher_def'); +select alter_column_sort_order_to_int('x_enum_element_def'); +select alter_column_sort_order_to_int('x_policy_resource_map'); +select alter_column_sort_order_to_int('x_policy_item'); +select alter_column_sort_order_to_int('x_policy_item_access'); +select alter_column_sort_order_to_int('x_policy_item_condition'); +select alter_column_sort_order_to_int('x_policy_item_user_perm'); +select alter_column_sort_order_to_int('x_policy_item_group_perm'); +select alter_column_sort_order_to_int('x_datamask_type_def'); diff --git a/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql b/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql index a7b1a40..4715584 100644 --- a/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql +++ b/security-admin/db/sqlanywhere/optimized/current/ranger_core_db_sqlanywhere.sql @@ -2161,6 +2161,8 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active GO INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('046',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); GO +INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); +GO INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); GO INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Reports'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1); diff --git a/security-admin/db/sqlanywhere/patches/047-sortorder-column-size.sql b/security-admin/db/sqlanywhere/patches/047-sortorder-column-size.sql new file mode 100644 index 0000000..d4b95e2 --- /dev/null +++ b/security-admin/db/sqlanywhere/patches/047-sortorder-column-size.sql @@ -0,0 +1,54 @@ +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +CREATE OR REPLACE PROCEDURE dbo.alterSortOrderColumn (IN table_name varchar(100)) +AS +BEGIN + DECLARE @stmt VARCHAR(300) + IF EXISTS(select * from SYS.SYSCOLUMNS where tname = table_name and cname='sort_order' and coltype='tinyint') + BEGIN + SET @stmt = 'ALTER TABLE dbo.' + table_name + ' ALTER sort_order INT DEFAULT 0 NULL' + execute(@stmt) + END +END +GO + +call dbo.alterSortOrderColumn('x_service_config_def') +GO +call dbo.alterSortOrderColumn('x_resource_def') +GO +call dbo.alterSortOrderColumn('x_access_type_def') +GO +call dbo.alterSortOrderColumn('x_policy_condition_def') +GO +call dbo.alterSortOrderColumn('x_context_enricher_def') +GO +call dbo.alterSortOrderColumn('x_enum_element_def') +GO +call dbo.alterSortOrderColumn('x_policy_resource_map') +GO +call dbo.alterSortOrderColumn('x_policy_item') +GO +call dbo.alterSortOrderColumn('x_policy_item_access') +GO +call dbo.alterSortOrderColumn('x_policy_item_condition') +GO +call dbo.alterSortOrderColumn('x_policy_item_user_perm') +GO +call dbo.alterSortOrderColumn('x_policy_item_group_perm') +GO +call dbo.alterSortOrderColumn('x_datamask_type_def') +GO +exit \ No newline at end of file diff --git a/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql b/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql index aaf19e7..1a966da 100644 --- a/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql +++ b/security-admin/db/sqlserver/optimized/current/ranger_core_db_sqlserver.sql @@ -3903,6 +3903,7 @@ INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('044',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('045',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('046',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); +INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('047',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); INSERT INTO x_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('DB_PATCHES',CURRENT_TIMESTAMP,'Ranger 1.0.0',CURRENT_TIMESTAMP,'localhost','Y'); INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Reports'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1); INSERT INTO x_user_module_perm (user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed) VALUES (dbo.getXportalUIdByLoginId('admin'),dbo.getModulesIdByName('Resource Based Policies'),CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,dbo.getXportalUIdByLoginId('admin'),dbo.getXportalUIdByLoginId('admin'),1); diff --git a/security-admin/db/sqlserver/patches/047-sortorder-column-size.sql b/security-admin/db/sqlserver/patches/047-sortorder-column-size.sql new file mode 100644 index 0000000..d812df6 --- /dev/null +++ b/security-admin/db/sqlserver/patches/047-sortorder-column-size.sql @@ -0,0 +1,82 @@ +-- Licensed to the Apache Software Foundation (ASF) under one or more +-- contributor license agreements. See the NOTICE file distributed with +-- this work for additional information regarding copyright ownership. +-- The ASF licenses this file to You under the Apache License, Version 2.0 +-- (the "License"); you may not use this file except in compliance with +-- the License. You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. + +SET ANSI_NULLS ON +GO +SET QUOTED_IDENTIFIER ON +GO +SET ANSI_PADDING ON +GO +IF EXISTS ( + SELECT type_desc, type + FROM sys.procedures WITH(NOLOCK) + WHERE NAME = 'alterSortOrderColumn' + AND type = 'P' + ) +BEGIN + PRINT 'Proc exist with name dbo.alterSortOrderColumn' + DROP PROCEDURE dbo.alterSortOrderColumn + PRINT 'Proc dropped dbo.alterSortOrderColumn' +END +GO +CREATE PROCEDURE dbo.alterSortOrderColumn + @tablename nvarchar(100) +AS +BEGIN + IF EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = @tablename and column_name = 'sort_order' and DATA_TYPE='tinyint') + BEGIN + DECLARE @ObjectName VARCHAR(100); + SELECT @ObjectName = OBJECT_NAME([default_object_id]) FROM SYS.COLUMNS WHERE [object_id] = OBJECT_ID('[dbo].[' + @tablename + ']') AND [name] = 'sort_order'; + IF @ObjectName IS NOT NULL + BEGIN + SET @stmt = 'ALTER TABLE [dbo].[' + @tablename + '] DROP CONSTRAINT ' + @ObjectName + EXEC (@stmt); + END + IF NOT EXISTS(select name from SYS.sysobjects where parent_obj in (select id from SYS.sysobjects where name=@tablename) and name=@ObjectName) + BEGIN + SET @stmt = 'ALTER TABLE [dbo].[' + @tablename + '] ALTER COLUMN [sort_order] [int]' + EXEC (@stmt); + END + END +END +GO + +EXEC dbo.alterSortOrderColumn 'x_service_config_def' +GO +EXEC dbo.alterSortOrderColumn 'x_resource_def' +GO +EXEC dbo.alterSortOrderColumn 'x_access_type_def' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_condition_def' +GO +EXEC dbo.alterSortOrderColumn 'x_context_enricher_def' +GO +EXEC dbo.alterSortOrderColumn 'x_enum_element_def' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_resource_map' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_item' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_item_access' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_item_condition' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_item_user_perm' +GO +EXEC dbo.alterSortOrderColumn 'x_policy_item_group_perm' +GO +EXEC dbo.alterSortOrderColumn 'x_datamask_type_def' +GO +EXIT \ No newline at end of file