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 9a79fe8ada..f1c092f1d9 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 @@ -602,16 +602,10 @@ CONSTRAINT `x_ranger_global_state_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERE CREATE TABLE IF NOT EXISTS `x_security_zone_ref_service`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `zone_id` bigint(20) NULL DEFAULT NULL, `service_id` bigint(20) NULL DEFAULT NULL, `service_name` varchar(255) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_sz_ref_service_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_sz_ref_service_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_sz_ref_service_FK_zone_id` FOREIGN KEY (`zone_id`) REFERENCES `x_security_zone` (`id`), CONSTRAINT `x_sz_ref_service_FK_service_id` FOREIGN KEY (`service_id`) REFERENCES `x_service` (`id`), CONSTRAINT `x_sz_ref_service_FK_service_name` FOREIGN KEY (`service_name`) REFERENCES `x_service` (`name`) @@ -619,16 +613,10 @@ CREATE TABLE IF NOT EXISTS `x_security_zone_ref_service`( CREATE TABLE IF NOT EXISTS `x_security_zone_ref_tag_srvc`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `zone_id` bigint(20) NULL DEFAULT NULL, `tag_srvc_id` bigint(20) NULL DEFAULT NULL, `tag_srvc_name` varchar(255) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_sz_ref_tag_service_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_sz_ref_tag_service_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_sz_ref_tag_service_FK_zone_id` FOREIGN KEY (`zone_id`) REFERENCES `x_security_zone` (`id`), CONSTRAINT `x_sz_ref_tag_service_FK_tag_srvc_id` FOREIGN KEY (`tag_srvc_id`) REFERENCES `x_service` (`id`), CONSTRAINT `x_sz_ref_tag_service_FK_tag_srvc_name` FOREIGN KEY (`tag_srvc_name`) REFERENCES `x_service` (`name`) @@ -636,17 +624,11 @@ CREATE TABLE IF NOT EXISTS `x_security_zone_ref_tag_srvc`( CREATE TABLE IF NOT EXISTS `x_security_zone_ref_user`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `zone_id` bigint(20) NULL DEFAULT NULL, `user_id` bigint(20) NULL DEFAULT NULL, `user_name` varchar(255) NULL DEFAULT NULL, `user_type` tinyint(3) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_sz_ref_user_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_sz_ref_user_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_sz_ref_user_FK_zone_id` FOREIGN KEY (`zone_id`) REFERENCES `x_security_zone` (`id`), CONSTRAINT `x_sz_ref_user_FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `x_user` (`id`), CONSTRAINT `x_sz_ref_user_FK_user_name` FOREIGN KEY (`user_name`) REFERENCES `x_user` (`user_name`) @@ -654,17 +636,11 @@ CREATE TABLE IF NOT EXISTS `x_security_zone_ref_user`( CREATE TABLE IF NOT EXISTS `x_security_zone_ref_group`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `zone_id` bigint(20) NULL DEFAULT NULL, `group_id` bigint(20) NULL DEFAULT NULL, `group_name` varchar(255) NULL DEFAULT NULL, `group_type` tinyint(3) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_sz_ref_group_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_sz_ref_group_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_sz_ref_group_FK_zone_id` FOREIGN KEY (`zone_id`) REFERENCES `x_security_zone` (`id`), CONSTRAINT `x_sz_ref_group_FK_group_id` FOREIGN KEY (`group_id`) REFERENCES `x_group` (`id`) )ROW_FORMAT=DYNAMIC; @@ -1322,124 +1298,76 @@ CREATE TABLE IF NOT EXISTS `x_ugsync_audit_info`( CREATE TABLE IF NOT EXISTS `x_policy_ref_resource` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `guid` varchar(1024) DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - `added_by_id` bigint(20) DEFAULT NULL, - `upd_by_id` bigint(20) DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `resource_def_id` bigint(20) NOT NULL, `resource_name` varchar(4000) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_res_UK_polId_resDefId`(`policy_id`, `resource_def_id`), - CONSTRAINT `x_policy_ref_res_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_res_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_res_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_res_FK_resource_def_id` FOREIGN KEY (`resource_def_id`) REFERENCES `x_resource_def` (`id`) ) ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_policy_ref_access_type` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `guid` varchar(1024) DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - `added_by_id` bigint(20) DEFAULT NULL, - `upd_by_id` bigint(20) DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `access_def_id` bigint(20) NOT NULL, `access_type_name` varchar(4000) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_access_UK_polId_accessDefId`(`policy_id`, `access_def_id`), - CONSTRAINT `x_policy_ref_access_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_access_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_access_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_access_FK_access_def_id` FOREIGN KEY (`access_def_id`) REFERENCES `x_access_type_def` (`id`) ) ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_policy_ref_condition` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `guid` varchar(1024) DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - `added_by_id` bigint(20) DEFAULT NULL, - `upd_by_id` bigint(20) DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `condition_def_id` bigint(20) NOT NULL, `condition_name` varchar(4000) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_condition_UK_polId_condDefId`(`policy_id`, `condition_def_id`), - CONSTRAINT `x_policy_ref_condition_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_condition_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_condition_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_condition_FK_condition_def_id` FOREIGN KEY (`condition_def_id`) REFERENCES `x_policy_condition_def` (`id`) ) ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_policy_ref_datamask_type` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `guid` varchar(1024) DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - `added_by_id` bigint(20) DEFAULT NULL, - `upd_by_id` bigint(20) DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `datamask_def_id` bigint(20) NOT NULL, `datamask_type_name` varchar(4000) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_datamask_UK_polId_dmaskDefId`(`policy_id`, `datamask_def_id`), - CONSTRAINT `x_policy_ref_datamask_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_datamask_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_datamask_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_datamask_FK_datamask_def_id` FOREIGN KEY (`datamask_def_id`) REFERENCES `x_datamask_type_def` (`id`) ) ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_policy_ref_user` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `guid` varchar(1024) DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - `added_by_id` bigint(20) DEFAULT NULL, - `upd_by_id` bigint(20) DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `user_id` bigint(20) NOT NULL, `user_name` varchar(4000) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_user_UK_polId_userId`(`policy_id`, `user_id`), - CONSTRAINT `x_policy_ref_user_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_user_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_user_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_user_FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `x_user` (`id`) ) ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_policy_ref_group` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, - `guid` varchar(1024) DEFAULT NULL, - `create_time` datetime DEFAULT NULL, - `update_time` datetime DEFAULT NULL, - `added_by_id` bigint(20) DEFAULT NULL, - `upd_by_id` bigint(20) DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `group_id` bigint(20) NOT NULL, `group_name` varchar(4000) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_group_UK_polId_groupId`(`policy_id`, `group_id`), - CONSTRAINT `x_policy_ref_group_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_group_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_group_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_group_FK_group_id` FOREIGN KEY (`group_id`) REFERENCES `x_group` (`id`) ) ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_security_zone_ref_resource`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `zone_id` bigint(20) NOT NULL, `resource_def_id` bigint(20) NOT NULL, `resource_name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_sz_ref_resource_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_sz_ref_resource_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_sz_ref_resource_FK_zone_id` FOREIGN KEY (`zone_id`) REFERENCES `x_security_zone` (`id`), CONSTRAINT `x_sz_ref_resource_FK_resource_def_id` FOREIGN KEY (`resource_def_id`) REFERENCES `x_resource_def` (`id`) ) ROW_FORMAT=DYNAMIC; @@ -1477,68 +1405,44 @@ CREATE TABLE IF NOT EXISTS `x_role`( CREATE TABLE IF NOT EXISTS `x_role_ref_user`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `role_id` bigint(20) NOT NULL, `user_id` bigint(20) NULL DEFAULT NULL, `user_name` varchar(767) NULL DEFAULT NULL, `priv_type` int(10) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_role_ref_user_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_role_ref_user_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_role_ref_user_FK_role_id` FOREIGN KEY (`role_id`) REFERENCES `x_role` (`id`), CONSTRAINT `x_role_ref_user_FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `x_user` (`id`) )ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_role_ref_group`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `role_id` bigint(20) NOT NULL, `group_id` bigint(20) NULL DEFAULT NULL, `group_name` varchar(767) NULL DEFAULT NULL, `priv_type` int(10) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_role_ref_group_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_role_ref_group_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_role_ref_group_FK_role_id` FOREIGN KEY (`role_id`) REFERENCES `x_role` (`id`), CONSTRAINT `x_role_ref_group_FK_group_id` FOREIGN KEY (`group_id`) REFERENCES `x_group` (`id`) )ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_policy_ref_role`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `policy_id` bigint(20) NOT NULL, `role_id` bigint(20) NOT NULL, `role_name` varchar(255) NULL DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `x_policy_ref_role_UK_polId_roleId`(`policy_id`, `role_id`), - CONSTRAINT `x_policy_ref_role_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_policy_ref_role_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_policy_ref_role_FK_policy_id` FOREIGN KEY (`policy_id`) REFERENCES `x_policy` (`id`), CONSTRAINT `x_policy_ref_role_FK_role_id` FOREIGN KEY (`role_id`) REFERENCES `x_role` (`id`) )ROW_FORMAT=DYNAMIC; CREATE TABLE IF NOT EXISTS `x_role_ref_role`( `id` bigint(20) NOT NULL AUTO_INCREMENT, -`create_time` datetime NULL DEFAULT NULL, -`update_time` datetime NULL DEFAULT NULL, -`added_by_id` bigint(20) NULL DEFAULT NULL, -`upd_by_id` bigint(20) NULL DEFAULT NULL, `role_ref_id` bigint(20) NULL DEFAULT NULL, `role_id` bigint(20) NOT NULL, `role_name` varchar(255) NULL DEFAULT NULL, `priv_type` int(10) NULL DEFAULT NULL, PRIMARY KEY (`id`), - CONSTRAINT `x_role_ref_role_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x_portal_user` (`id`), - CONSTRAINT `x_role_ref_role_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`), CONSTRAINT `x_role_ref_role_FK_role_ref_id` FOREIGN KEY (`role_ref_id`) REFERENCES `x_role` (`id`) )ROW_FORMAT=DYNAMIC; @@ -1813,6 +1717,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 ('058',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 ('059',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 ('060',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 ('061',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_db_version_h (version,inst_at,inst_by,updated_at,updated_by,active) VALUES ('J10001',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y'); diff --git a/security-admin/db/mysql/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/mysql/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql new file mode 100644 index 0000000000..9d22685b1b --- /dev/null +++ b/security-admin/db/mysql/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql @@ -0,0 +1,156 @@ +-- 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. + +-- Commented because dropping this column would break high-availability setups +-- We can uncomment this after the next major version upgrade +/* +drop procedure if exists drop_table_column; +delimiter ;; +create procedure drop_table_column(IN tableName varchar(64), IN columnName varchar(64)) begin + if exists (select * from information_schema.columns where table_schema=database() and table_name = tableName and column_name = columnName) then + SET @query = CONCAT('ALTER TABLE `', tableName,'` DROP COLUMN `', columnName,'`'); + PREPARE stmt FROM @query; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; + end if; +end;; +delimiter ; + +drop procedure if exists drop_table_foreign_key; +delimiter ;; +create procedure drop_table_foreign_key(IN tableName varchar(64), IN foreignKeyName varchar(64)) begin + if exists (select * from information_schema.table_constraints where table_schema=database() and table_name = tableName and constraint_name = foreignKeyName and constraint_type = 'FOREIGN KEY') then + SET @query = CONCAT('ALTER TABLE `', tableName,'` DROP FOREIGN KEY `', foreignKeyName,'`'); + PREPARE stmt FROM @query; + EXECUTE stmt; + DEALLOCATE PREPARE stmt; + end if; +end;; +delimiter ; + +call drop_table_column('x_policy_ref_resource', 'guid'); +call drop_table_column('x_policy_ref_resource', 'create_time'); +call drop_table_column('x_policy_ref_resource', 'update_time'); +call drop_table_foreign_key('x_policy_ref_resource', 'x_policy_ref_res_FK_added_by_id'); +call drop_table_column('x_policy_ref_resource', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_resource', 'x_policy_ref_res_FK_upd_by_id'); +call drop_table_column('x_policy_ref_resource', 'upd_by_id'); + +call drop_table_column('x_policy_ref_role', 'create_time'); +call drop_table_column('x_policy_ref_role', 'update_time'); +call drop_table_foreign_key('x_policy_ref_role', 'x_policy_ref_role_FK_added_by_id'); +call drop_table_column('x_policy_ref_role', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_role', 'x_policy_ref_role_FK_upd_by_id'); +call drop_table_column('x_policy_ref_role', 'upd_by_id'); + +call drop_table_column('x_policy_ref_group', 'guid'); +call drop_table_column('x_policy_ref_group', 'create_time'); +call drop_table_column('x_policy_ref_group', 'update_time'); +call drop_table_foreign_key('x_policy_ref_group', 'x_policy_ref_group_FK_added_by_id'); +call drop_table_column('x_policy_ref_group', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_group', 'x_policy_ref_group_FK_upd_by_id'); +call drop_table_column('x_policy_ref_group', 'upd_by_id'); + +call drop_table_column('x_policy_ref_user', 'guid'); +call drop_table_column('x_policy_ref_user', 'create_time'); +call drop_table_column('x_policy_ref_user', 'update_time'); +call drop_table_foreign_key('x_policy_ref_user', 'x_policy_ref_user_FK_added_by_id'); +call drop_table_column('x_policy_ref_user', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_user', 'x_policy_ref_user_FK_upd_by_id'); +call drop_table_column('x_policy_ref_user', 'upd_by_id'); + +call drop_table_column('x_policy_ref_access_type', 'guid'); +call drop_table_column('x_policy_ref_access_type', 'create_time'); +call drop_table_column('x_policy_ref_access_type', 'update_time'); +call drop_table_foreign_key('x_policy_ref_access_type', 'x_policy_ref_access_FK_added_by_id'); +call drop_table_column('x_policy_ref_access_type', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_access_type', 'x_policy_ref_access_FK_upd_by_id'); +call drop_table_column('x_policy_ref_access_type', 'upd_by_id'); + +call drop_table_column('x_policy_ref_condition', 'guid'); +call drop_table_column('x_policy_ref_condition', 'create_time'); +call drop_table_column('x_policy_ref_condition', 'update_time'); +call drop_table_foreign_key('x_policy_ref_condition', 'x_policy_ref_condition_FK_added_by_id'); +call drop_table_column('x_policy_ref_condition', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_condition', 'x_policy_ref_condition_FK_upd_by_id'); +call drop_table_column('x_policy_ref_condition', 'upd_by_id'); + +call drop_table_column('x_policy_ref_datamask_type', 'guid'); +call drop_table_column('x_policy_ref_datamask_type', 'create_time'); +call drop_table_column('x_policy_ref_datamask_type', 'update_time'); +call drop_table_foreign_key('x_policy_ref_datamask_type', 'x_policy_ref_datamask_FK_added_by_id'); +call drop_table_column('x_policy_ref_datamask_type', 'added_by_id'); +call drop_table_foreign_key('x_policy_ref_datamask_type', 'x_policy_ref_datamask_FK_upd_by_id'); +call drop_table_column('x_policy_ref_datamask_type', 'upd_by_id'); + +call drop_table_column('x_security_zone_ref_service', 'create_time'); +call drop_table_column('x_security_zone_ref_service', 'update_time'); +call drop_table_foreign_key('x_security_zone_ref_service', 'x_sz_ref_service_FK_added_by_id'); +call drop_table_column('x_security_zone_ref_service', 'added_by_id'); +call drop_table_foreign_key('x_security_zone_ref_service', 'x_sz_ref_service_FK_upd_by_id'); +call drop_table_column('x_security_zone_ref_service', 'upd_by_id'); + +call drop_table_column('x_security_zone_ref_tag_srvc', 'create_time'); +call drop_table_column('x_security_zone_ref_tag_srvc', 'update_time'); +call drop_table_foreign_key('x_security_zone_ref_tag_srvc', 'x_sz_ref_tag_service_FK_added_by_id'); +call drop_table_column('x_security_zone_ref_tag_srvc', 'added_by_id'); +call drop_table_foreign_key('x_security_zone_ref_tag_srvc', 'x_sz_ref_tag_service_FK_upd_by_id'); +call drop_table_column('x_security_zone_ref_tag_srvc', 'upd_by_id'); + +call drop_table_column('x_security_zone_ref_user', 'create_time'); +call drop_table_column('x_security_zone_ref_user', 'update_time'); +call drop_table_foreign_key('x_security_zone_ref_user', 'x_sz_ref_user_FK_added_by_id'); +call drop_table_column('x_security_zone_ref_user', 'added_by_id'); +call drop_table_foreign_key('x_security_zone_ref_user', 'x_sz_ref_user_FK_upd_by_id'); +call drop_table_column('x_security_zone_ref_user', 'upd_by_id'); + +call drop_table_column('x_security_zone_ref_group', 'create_time'); +call drop_table_column('x_security_zone_ref_group', 'update_time'); +call drop_table_foreign_key('x_security_zone_ref_group', 'x_sz_ref_group_FK_added_by_id'); +call drop_table_column('x_security_zone_ref_group', 'added_by_id'); +call drop_table_foreign_key('x_security_zone_ref_group', 'x_sz_ref_group_FK_upd_by_id'); +call drop_table_column('x_security_zone_ref_group', 'upd_by_id'); + +call drop_table_column('x_security_zone_ref_resource', 'create_time'); +call drop_table_column('x_security_zone_ref_resource', 'update_time'); +call drop_table_foreign_key('x_security_zone_ref_resource', 'x_sz_ref_resource_FK_added_by_id'); +call drop_table_column('x_security_zone_ref_resource', 'added_by_id'); +call drop_table_foreign_key('x_security_zone_ref_resource', 'x_sz_ref_resource_FK_upd_by_id'); +call drop_table_column('x_security_zone_ref_resource', 'upd_by_id'); + +call drop_table_column('x_role_ref_user', 'create_time'); +call drop_table_column('x_role_ref_user', 'update_time'); +call drop_table_foreign_key('x_role_ref_user', 'x_role_ref_user_FK_added_by_id'); +call drop_table_column('x_role_ref_user', 'added_by_id'); +call drop_table_foreign_key('x_role_ref_user', 'x_role_ref_user_FK_upd_by_id'); +call drop_table_column('x_role_ref_user', 'upd_by_id'); + +call drop_table_column('x_role_ref_group', 'create_time'); +call drop_table_column('x_role_ref_group', 'update_time'); +call drop_table_foreign_key('x_role_ref_group', 'x_role_ref_group_FK_added_by_id'); +call drop_table_column('x_role_ref_group', 'added_by_id'); +call drop_table_foreign_key('x_role_ref_group', 'x_role_ref_group_FK_upd_by_id'); +call drop_table_column('x_role_ref_group', 'upd_by_id'); + +call drop_table_column('x_role_ref_role', 'create_time'); +call drop_table_column('x_role_ref_role', 'update_time'); +call drop_table_foreign_key('x_role_ref_role', 'x_role_ref_role_FK_added_by_id'); +call drop_table_column('x_role_ref_role', 'added_by_id'); +call drop_table_foreign_key('x_role_ref_role', 'x_role_ref_role_FK_upd_by_id'); +call drop_table_column('x_role_ref_role', 'upd_by_id'); + +drop procedure if exists drop_table_column; +drop procedure if exists drop_table_foreign_key; +*/ 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 fd6cec9a77..dd59e07b79 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 @@ -704,16 +704,10 @@ commit; CREATE TABLE x_security_zone_ref_service ( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, zone_id NUMBER(20) DEFAULT NULL NULL, service_id NUMBER(20) DEFAULT NULL NULL, service_name VARCHAR(255) DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_ref_ser_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_ser_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_ser_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_ser_FK_service_id FOREIGN KEY (service_id) REFERENCES x_service (id), CONSTRAINT x_sz_ref_ser_FK_service_name FOREIGN KEY (service_name) REFERENCES x_service (name) @@ -722,16 +716,10 @@ commit; CREATE TABLE x_security_zone_ref_tag_srvc ( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, zone_id NUMBER(20) DEFAULT NULL NULL, tag_srvc_id NUMBER(20) DEFAULT NULL NULL, tag_srvc_name VARCHAR(255) DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_refTagTser_FK_aded_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_refTagTser_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_refTagTser_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_refTagTser_FK_srvc_id FOREIGN KEY (tag_srvc_id) REFERENCES x_service (id), CONSTRAINT x_sz_refTagTser_FK_srvc_name FOREIGN KEY (tag_srvc_name) REFERENCES x_service (name) @@ -740,17 +728,11 @@ commit; CREATE TABLE x_security_zone_ref_user ( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, zone_id NUMBER(20) DEFAULT NULL NULL, user_id NUMBER(20) DEFAULT NULL NULL, user_name varchar(255) DEFAULT NULL NULL, user_type NUMBER(3) DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_ref_user_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_user_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_user_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_user_FK_user_id FOREIGN KEY (user_id) REFERENCES x_user (id), CONSTRAINT x_sz_ref_user_FK_user_name FOREIGN KEY (user_name) REFERENCES x_user (user_name) @@ -759,17 +741,11 @@ commit; CREATE TABLE x_security_zone_ref_group ( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, zone_id NUMBER(20) DEFAULT NULL NULL, group_id NUMBER(20) DEFAULT NULL NULL, group_name varchar(255) DEFAULT NULL NULL, group_type NUMBER(3) DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_ref_group_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_group_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_group_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_group_FK_group_id FOREIGN KEY (group_id) REFERENCES x_group (id) ); @@ -1395,110 +1371,68 @@ commit; CREATE TABLE x_policy_ref_resource ( id NUMBER(20) NOT NULL, -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, resource_def_id NUMBER(20) NOT NULL, resource_name VARCHAR(4000) DEFAULT NULL NULL, primary key (id), CONSTRAINT x_p_ref_res_UK_polId_resDefId UNIQUE (policy_id, resource_def_id), CONSTRAINT x_p_ref_res_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), -CONSTRAINT x_p_ref_res_FK_resource_def_id FOREIGN KEY (resource_def_id) REFERENCES x_resource_def (id), -CONSTRAINT x_p_ref_res_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_p_ref_res_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id) +CONSTRAINT x_p_ref_res_FK_resource_def_id FOREIGN KEY (resource_def_id) REFERENCES x_resource_def (id) ); commit; CREATE TABLE x_policy_ref_access_type ( id NUMBER(20) NOT NULL, -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, access_def_id NUMBER(20) NOT NULL, access_type_name VARCHAR(4000) DEFAULT NULL NULL, primary key (id), CONSTRAINT x_p_ref_acc_UK_polId_accDefId UNIQUE(policy_id, access_def_id), CONSTRAINT x_p_ref_acc_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), -CONSTRAINT x_p_ref_acc_FK_acc_def_id FOREIGN KEY (access_def_id) REFERENCES x_access_type_def (id), -CONSTRAINT x_p_ref_acc_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_p_ref_acc_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id) +CONSTRAINT x_p_ref_acc_FK_acc_def_id FOREIGN KEY (access_def_id) REFERENCES x_access_type_def (id) ); commit; CREATE TABLE x_policy_ref_condition ( id NUMBER(20) NOT NULL, -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, condition_def_id NUMBER(20) NOT NULL, condition_name VARCHAR(4000) DEFAULT NULL NULL, primary key (id), CONSTRAINT x_p_ref_cond_UK_polId_cDefId UNIQUE(policy_id, condition_def_id), CONSTRAINT x_p_ref_cond_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), -CONSTRAINT x_p_ref_cond_FK_cond_def_id FOREIGN KEY (condition_def_id) REFERENCES x_policy_condition_def (id), -CONSTRAINT x_p_ref_cond_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_p_ref_cond_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id) +CONSTRAINT x_p_ref_cond_FK_cond_def_id FOREIGN KEY (condition_def_id) REFERENCES x_policy_condition_def (id) ); commit; CREATE TABLE x_policy_ref_datamask_type ( id NUMBER(20) NOT NULL, -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, datamask_def_id NUMBER(20) NOT NULL, datamask_type_name VARCHAR(4000) DEFAULT NULL NULL, primary key (id), CONSTRAINT x_p_ref_dmsk_UK_polId_dDefId UNIQUE(policy_id, datamask_def_id), CONSTRAINT x_p_ref_dmsk_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), -CONSTRAINT x_p_ref_dmsk_FK_dmk_def_id FOREIGN KEY (datamask_def_id) REFERENCES x_datamask_type_def (id), -CONSTRAINT x_p_ref_dmsk_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_p_ref_dmsk_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id) +CONSTRAINT x_p_ref_dmsk_FK_dmk_def_id FOREIGN KEY (datamask_def_id) REFERENCES x_datamask_type_def (id) ); commit; CREATE TABLE x_policy_ref_user ( id NUMBER(20) NOT NULL, -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, user_id NUMBER(20) NOT NULL, user_name VARCHAR(4000) DEFAULT NULL NULL, primary key (id), CONSTRAINT x_p_ref_usr_UK_polId_userId UNIQUE(policy_id, user_id), CONSTRAINT x_p_ref_usr_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), -CONSTRAINT x_p_ref_usr_FK_user_id FOREIGN KEY (user_id) REFERENCES x_user (id), -CONSTRAINT x_p_ref_usr_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_p_ref_usr_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id) +CONSTRAINT x_p_ref_usr_FK_user_id FOREIGN KEY (user_id) REFERENCES x_user (id) ); commit; CREATE TABLE x_policy_ref_group ( id NUMBER(20) NOT NULL, -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, group_id NUMBER(20) NOT NULL, group_name VARCHAR(4000) DEFAULT NULL NULL, primary key (id), CONSTRAINT x_p_ref_grp_UK_polId_grpId UNIQUE(policy_id, group_id), CONSTRAINT x_p_ref_grp_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), -CONSTRAINT x_p_ref_grp_FK_group_id FOREIGN KEY (group_id) REFERENCES x_group (id), -CONSTRAINT x_p_ref_grp_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_p_ref_grp_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id) +CONSTRAINT x_p_ref_grp_FK_group_id FOREIGN KEY (group_id) REFERENCES x_group (id) ); commit; CREATE TABLE x_policy_change_log( @@ -1554,17 +1488,11 @@ commit; CREATE TABLE x_role_ref_user( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, role_id NUMBER(20) NOT NULL, user_id NUMBER(20) DEFAULT NULL NULL, user_name varchar(767) DEFAULT NULL NULL, priv_type NUMBER(10) DEFAULT NULL NULL, PRIMARY KEY (id), - CONSTRAINT x_role_ref_user_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_role_ref_user_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_role_ref_user_FK_role_id FOREIGN KEY (role_id) REFERENCES x_role (id), CONSTRAINT x_role_ref_user_FK_user_id FOREIGN KEY (user_id) REFERENCES x_user (id) ); @@ -1572,17 +1500,11 @@ commit; CREATE TABLE x_role_ref_group( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, role_id NUMBER(20) NOT NULL, group_id NUMBER(20) DEFAULT NULL NULL, group_name varchar(767) DEFAULT NULL NULL, priv_type NUMBER(10) DEFAULT NULL NULL, PRIMARY KEY (id), - CONSTRAINT x_role_ref_grp_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_role_ref_grp_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_role_ref_grp_FK_role_id FOREIGN KEY (role_id) REFERENCES x_role (id), CONSTRAINT x_role_ref_grp_FK_group_id FOREIGN KEY (group_id) REFERENCES x_group (id) ); @@ -1591,17 +1513,11 @@ commit; CREATE TABLE x_policy_ref_role( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, policy_id NUMBER(20) NOT NULL, role_id NUMBER(20) NOT NULL, role_name varchar(255) DEFAULT NULL NULL, PRIMARY KEY (id), CONSTRAINT x_pol_ref_role_UK_polId_roleId UNIQUE(policy_id,role_id), - CONSTRAINT x_pol_ref_role_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_pol_ref_role_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_pol_ref_role_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), CONSTRAINT x_pol_ref_role_FK_role_id FOREIGN KEY (role_id) REFERENCES x_role (id) ); @@ -1609,33 +1525,21 @@ commit; CREATE TABLE x_role_ref_role( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, role_ref_id NUMBER(20) DEFAULT NULL NULL, role_id NUMBER(20) NOT NULL, role_name varchar(255) DEFAULT NULL NULL, priv_type NUMBER(10) DEFAULT NULL NULL, PRIMARY KEY (id), - CONSTRAINT x_role_ref_role_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_role_ref_role_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_role_ref_role_FK_role_ref_id FOREIGN KEY (role_ref_id) REFERENCES x_role (id) ); commit; CREATE TABLE x_security_zone_ref_resource ( id NUMBER(20) NOT NULL, -create_time DATE DEFAULT NULL NULL, -update_time DATE DEFAULT NULL NULL, -added_by_id NUMBER(20) DEFAULT NULL NULL, -upd_by_id NUMBER(20) DEFAULT NULL NULL, zone_id NUMBER(20) DEFAULT NULL NULL, resource_def_id NUMBER(20) DEFAULT NULL NULL, resource_name VARCHAR(255) DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_ref_res_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_res_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_res_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_res_FK_res_def_id FOREIGN KEY (resource_def_id) REFERENCES x_resource_def (id) ); @@ -1973,6 +1877,7 @@ 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, '058',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, '059',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, '060',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, '061',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); diff --git a/security-admin/db/oracle/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/oracle/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql new file mode 100644 index 0000000000..4dbba4ae43 --- /dev/null +++ b/security-admin/db/oracle/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql @@ -0,0 +1,111 @@ +-- 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. + +-- Commented because dropping this column would break high-availability setups +-- We can uncomment this after the next major version upgrade +/* +CREATE OR REPLACE PROCEDURE spdroptablecolumn(TableName IN varchar2, ColumnName IN varchar2) +IS + v_column_exists number := 0; +BEGIN + select count(*) into v_column_exists from user_tab_cols where table_name = upper(TableName) and column_name = upper(ColumnName); + if (v_column_exists > 0) then + execute immediate 'ALTER TABLE ' || TableName || ' DROP COLUMN ' || ColumnName || ' CASCADE CONSTRAINTS'; + commit; + end if; +END; +/ + +call spdroptablecolumn('x_policy_ref_resource', 'guid'); +call spdroptablecolumn('x_policy_ref_resource', 'create_time'); +call spdroptablecolumn('x_policy_ref_resource', 'update_time'); +call spdroptablecolumn('x_policy_ref_resource', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_resource', 'upd_by_id'); + +call spdroptablecolumn('x_policy_ref_role', 'create_time'); +call spdroptablecolumn('x_policy_ref_role', 'update_time'); +call spdroptablecolumn('x_policy_ref_role', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_role', 'upd_by_id'); + +call spdroptablecolumn('x_policy_ref_group', 'guid'); +call spdroptablecolumn('x_policy_ref_group', 'create_time'); +call spdroptablecolumn('x_policy_ref_group', 'update_time'); +call spdroptablecolumn('x_policy_ref_group', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_group', 'upd_by_id'); + +call spdroptablecolumn('x_policy_ref_user', 'guid'); +call spdroptablecolumn('x_policy_ref_user', 'create_time'); +call spdroptablecolumn('x_policy_ref_user', 'update_time'); +call spdroptablecolumn('x_policy_ref_user', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_user', 'upd_by_id'); + +call spdroptablecolumn('x_policy_ref_access_type', 'guid'); +call spdroptablecolumn('x_policy_ref_access_type', 'create_time'); +call spdroptablecolumn('x_policy_ref_access_type', 'update_time'); +call spdroptablecolumn('x_policy_ref_access_type', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_access_type', 'upd_by_id'); + +call spdroptablecolumn('x_policy_ref_condition', 'guid'); +call spdroptablecolumn('x_policy_ref_condition', 'create_time'); +call spdroptablecolumn('x_policy_ref_condition', 'update_time'); +call spdroptablecolumn('x_policy_ref_condition', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_condition', 'upd_by_id'); + +call spdroptablecolumn('x_policy_ref_datamask_type', 'guid'); +call spdroptablecolumn('x_policy_ref_datamask_type', 'create_time'); +call spdroptablecolumn('x_policy_ref_datamask_type', 'update_time'); +call spdroptablecolumn('x_policy_ref_datamask_type', 'added_by_id'); +call spdroptablecolumn('x_policy_ref_datamask_type', 'upd_by_id'); + +call spdroptablecolumn('x_security_zone_ref_service', 'create_time'); +call spdroptablecolumn('x_security_zone_ref_service', 'update_time'); +call spdroptablecolumn('x_security_zone_ref_service', 'added_by_id'); +call spdroptablecolumn('x_security_zone_ref_service', 'upd_by_id'); + +call spdroptablecolumn('x_security_zone_ref_tag_srvc', 'create_time'); +call spdroptablecolumn('x_security_zone_ref_tag_srvc', 'update_time'); +call spdroptablecolumn('x_security_zone_ref_tag_srvc', 'added_by_id'); +call spdroptablecolumn('x_security_zone_ref_tag_srvc', 'upd_by_id'); + +call spdroptablecolumn('x_security_zone_ref_user', 'create_time'); +call spdroptablecolumn('x_security_zone_ref_user', 'update_time'); +call spdroptablecolumn('x_security_zone_ref_user', 'added_by_id'); +call spdroptablecolumn('x_security_zone_ref_user', 'upd_by_id'); + +call spdroptablecolumn('x_security_zone_ref_group', 'create_time'); +call spdroptablecolumn('x_security_zone_ref_group', 'update_time'); +call spdroptablecolumn('x_security_zone_ref_group', 'added_by_id'); +call spdroptablecolumn('x_security_zone_ref_group', 'upd_by_id'); + +call spdroptablecolumn('x_security_zone_ref_resource', 'create_time'); +call spdroptablecolumn('x_security_zone_ref_resource', 'update_time'); +call spdroptablecolumn('x_security_zone_ref_resource', 'added_by_id'); +call spdroptablecolumn('x_security_zone_ref_resource', 'upd_by_id'); + +call spdroptablecolumn('x_role_ref_user', 'create_time'); +call spdroptablecolumn('x_role_ref_user', 'update_time'); +call spdroptablecolumn('x_role_ref_user', 'added_by_id'); +call spdroptablecolumn('x_role_ref_user', 'upd_by_id'); + +call spdroptablecolumn('x_role_ref_group', 'create_time'); +call spdroptablecolumn('x_role_ref_group', 'update_time'); +call spdroptablecolumn('x_role_ref_group', 'added_by_id'); +call spdroptablecolumn('x_role_ref_group', 'upd_by_id'); + +call spdroptablecolumn('x_role_ref_role', 'create_time'); +call spdroptablecolumn('x_role_ref_role', 'update_time'); +call spdroptablecolumn('x_role_ref_role', 'added_by_id'); +call spdroptablecolumn('x_role_ref_role', 'upd_by_id'); +*/ 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 4d5a8cedfc..df867e3790 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 @@ -1254,40 +1254,26 @@ primary key (id) CREATE SEQUENCE x_policy_ref_resource_seq; CREATE TABLE x_policy_ref_resource( id BIGINT DEFAULT nextval('x_policy_ref_resource_seq'::regclass), -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, resource_def_id BIGINT NOT NULL, resource_name varchar(4000) DEFAULT NULL, primary key(id), CONSTRAINT x_p_ref_res_UK_polId_resDefId UNIQUE (policy_id, resource_def_id), CONSTRAINT x_p_ref_res_FK_policy_id FOREIGN KEY(policy_id) REFERENCES x_policy(id), -CONSTRAINT x_p_ref_res_FK_resource_def_id FOREIGN KEY(resource_def_id) REFERENCES x_resource_def(id), -CONSTRAINT x_p_ref_res_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_portal_user(id), -CONSTRAINT x_p_ref_res_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id) +CONSTRAINT x_p_ref_res_FK_resource_def_id FOREIGN KEY(resource_def_id) REFERENCES x_resource_def(id) ); commit; CREATE SEQUENCE x_policy_ref_access_type_seq; CREATE TABLE x_policy_ref_access_type( id BIGINT DEFAULT nextval('x_policy_ref_access_type_seq'::regclass), -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, access_def_id BIGINT NOT NULL, access_type_name varchar(4000) DEFAULT NULL, primary key(id), CONSTRAINT x_p_ref_acc_UK_polId_accDefId UNIQUE(policy_id, access_def_id), CONSTRAINT x_p_ref_acc_FK_policy_id FOREIGN KEY(policy_id) REFERENCES x_policy(id), -CONSTRAINT x_p_ref_acc_FK_acc_def_id FOREIGN KEY(access_def_id) REFERENCES x_access_type_def(id), -CONSTRAINT x_p_ref_acc_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_portal_user(id), -CONSTRAINT x_p_ref_acc_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id) +CONSTRAINT x_p_ref_acc_FK_acc_def_id FOREIGN KEY(access_def_id) REFERENCES x_access_type_def(id) ); commit; DROP TABLE IF EXISTS x_policy_ref_condition CASCADE; @@ -1295,96 +1281,62 @@ DROP SEQUENCE IF EXISTS x_policy_ref_condition_seq; CREATE SEQUENCE x_policy_ref_condition_seq; CREATE TABLE x_policy_ref_condition( id BIGINT DEFAULT nextval('x_policy_ref_condition_seq'::regclass), -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, condition_def_id BIGINT NOT NULL, condition_name varchar(4000) DEFAULT NULL, primary key(id), CONSTRAINT x_p_ref_cond_UK_polId_cDefId UNIQUE(policy_id, condition_def_id), CONSTRAINT x_p_ref_cond_FK_policy_id FOREIGN KEY(policy_id) REFERENCES x_policy(id), -CONSTRAINT x_p_ref_cond_FK_cond_def_id FOREIGN KEY(condition_def_id) REFERENCES x_policy_condition_def(id), -CONSTRAINT x_p_ref_cond_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_portal_user(id), -CONSTRAINT x_p_ref_cond_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id) +CONSTRAINT x_p_ref_cond_FK_cond_def_id FOREIGN KEY(condition_def_id) REFERENCES x_policy_condition_def(id) ); commit; CREATE SEQUENCE x_policy_ref_datamask_type_seq; CREATE TABLE x_policy_ref_datamask_type( id BIGINT DEFAULT nextval('x_policy_ref_datamask_type_seq'::regclass), -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, datamask_def_id BIGINT NOT NULL, datamask_type_name varchar(4000) DEFAULT NULL, primary key(id), CONSTRAINT x_p_ref_dmk_UK_polId_dDefId UNIQUE(policy_id, datamask_def_id), CONSTRAINT x_p_ref_dmk_FK_policy_id FOREIGN KEY(policy_id) REFERENCES x_policy(id), -CONSTRAINT x_p_ref_dmk_FK_dmk_def_id FOREIGN KEY(datamask_def_id) REFERENCES x_datamask_type_def(id), -CONSTRAINT x_p_ref_dmk_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_portal_user(id), -CONSTRAINT x_p_ref_dmk_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id) +CONSTRAINT x_p_ref_dmk_FK_dmk_def_id FOREIGN KEY(datamask_def_id) REFERENCES x_datamask_type_def(id) ); commit; CREATE SEQUENCE x_policy_ref_user_seq; CREATE TABLE x_policy_ref_user( id BIGINT DEFAULT nextval('x_policy_ref_user_seq'::regclass), -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, user_id BIGINT NOT NULL, user_name varchar(4000) DEFAULT NULL, primary key(id), CONSTRAINT x_p_ref_usr_UK_polId_userId UNIQUE(policy_id, user_id), CONSTRAINT x_p_ref_usr_FK_policy_id FOREIGN KEY(policy_id) REFERENCES x_policy(id), -CONSTRAINT x_p_ref_usr_FK_user_id FOREIGN KEY(user_id) REFERENCES x_user(id), -CONSTRAINT x_p_ref_usr_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_portal_user(id), -CONSTRAINT x_p_ref_usr_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id) +CONSTRAINT x_p_ref_usr_FK_user_id FOREIGN KEY(user_id) REFERENCES x_user(id) ); commit; CREATE SEQUENCE x_policy_ref_group_seq; CREATE TABLE x_policy_ref_group( id BIGINT DEFAULT nextval('x_policy_ref_group_seq'::regclass), -guid VARCHAR(1024) DEFAULT NULL NULL, -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, group_id BIGINT NOT NULL, group_name varchar(4000) DEFAULT NULL, primary key(id), CONSTRAINT x_p_ref_grp_UK_polId_grpId UNIQUE(policy_id, group_id), CONSTRAINT x_p_ref_grp_FK_policy_id FOREIGN KEY(policy_id) REFERENCES x_policy(id), -CONSTRAINT x_p_ref_grp_FK_group_id FOREIGN KEY(group_id) REFERENCES x_group(id), -CONSTRAINT x_p_ref_grp_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_portal_user(id), -CONSTRAINT x_p_ref_grp_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id) +CONSTRAINT x_p_ref_grp_FK_group_id FOREIGN KEY(group_id) REFERENCES x_group(id) ); commit; CREATE SEQUENCE x_sec_zone_ref_service_seq; CREATE TABLE x_security_zone_ref_service ( id BIGINT DEFAULT nextval('x_sec_zone_ref_service_seq'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, zone_id BIGINT DEFAULT NULL NULL, service_id BIGINT DEFAULT NULL NULL, service_name varchar(255) NULL DEFAULT NULL::character varying, primary key (id), -CONSTRAINT x_sz_ref_service_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_service_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_service_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_service_FK_service_id FOREIGN KEY (service_id) REFERENCES x_service (id), CONSTRAINT x_sz_ref_service_FK_service_name FOREIGN KEY (service_name) REFERENCES x_service (name) @@ -1393,16 +1345,10 @@ CONSTRAINT x_sz_ref_service_FK_service_name FOREIGN KEY (service_name) REFERENCE CREATE SEQUENCE x_sec_zone_ref_tag_srvc_seq; CREATE TABLE x_security_zone_ref_tag_srvc ( id BIGINT DEFAULT nextval('x_sec_zone_ref_tag_srvc_SEQ'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, zone_id BIGINT DEFAULT NULL NULL, tag_srvc_id BIGINT DEFAULT NULL NULL, tag_srvc_name varchar(255) NULL DEFAULT NULL::character varying, primary key (id), -CONSTRAINT x_sz_refTagSrvc_FK_aded_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_refTagSrvc_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_refTagSrvc_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_refTagSrvc_FK_tag_srvc_id FOREIGN KEY (tag_srvc_id) REFERENCES x_service (id), CONSTRAINT x_sz_refTagSrvc_FK_tag_srvc_name FOREIGN KEY (tag_srvc_name) REFERENCES x_service (name) @@ -1411,16 +1357,10 @@ CONSTRAINT x_sz_refTagSrvc_FK_tag_srvc_name FOREIGN KEY (tag_srvc_name) REFERENC CREATE SEQUENCE x_sec_zone_ref_resource_seq; CREATE TABLE x_security_zone_ref_resource ( id BIGINT DEFAULT nextval('x_sec_zone_ref_resource_seq'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, zone_id BIGINT DEFAULT NULL NULL, resource_def_id BIGINT DEFAULT NULL NULL, resource_name varchar(255) NULL DEFAULT NULL::character varying, primary key (id), -CONSTRAINT x_sz_ref_res_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_res_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_service_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_res_FK_resource_def_id FOREIGN KEY (resource_def_id) REFERENCES x_resource_def (id) ); @@ -1428,17 +1368,11 @@ CONSTRAINT x_sz_ref_res_FK_resource_def_id FOREIGN KEY (resource_def_id) REFEREN CREATE SEQUENCE x_sec_zone_ref_user_seq; CREATE TABLE x_security_zone_ref_user ( id BIGINT DEFAULT nextval('x_sec_zone_ref_user_seq'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, zone_id BIGINT DEFAULT NULL NULL, user_id BIGINT DEFAULT NULL NULL, user_name varchar(255) NULL DEFAULT NULL::character varying, user_type SMALLINT DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_ref_user_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_user_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_user_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_user_FK_user_id FOREIGN KEY (user_id) REFERENCES x_user (id), CONSTRAINT x_sz_ref_user_FK_user_name FOREIGN KEY (user_name) REFERENCES x_user (user_name) @@ -1447,17 +1381,11 @@ CONSTRAINT x_sz_ref_user_FK_user_name FOREIGN KEY (user_name) REFERENCES x_user CREATE SEQUENCE x_sec_zone_ref_group_seq; CREATE TABLE x_security_zone_ref_group ( id BIGINT DEFAULT nextval('x_sec_zone_ref_group_seq'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, zone_id BIGINT DEFAULT NULL NULL, group_id BIGINT DEFAULT NULL NULL, group_name varchar(255) NULL DEFAULT NULL::character varying, group_type SMALLINT DEFAULT NULL NULL, primary key (id), -CONSTRAINT x_sz_ref_group_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), -CONSTRAINT x_sz_ref_group_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_sz_ref_group_FK_zone_id FOREIGN KEY (zone_id) REFERENCES x_security_zone (id), CONSTRAINT x_sz_ref_group_FK_group_id FOREIGN KEY (group_id) REFERENCES x_group (id) ); @@ -1501,17 +1429,11 @@ commit; CREATE SEQUENCE x_role_ref_user_SEQ; CREATE TABLE x_role_ref_user( id BIGINT DEFAULT nextval('x_role_ref_user_SEQ'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, role_id BIGINT NOT NULL, user_id BIGINT DEFAULT NULL NULL, user_name varchar(767) DEFAULT NULL NULL, priv_type INT DEFAULT NULL NULL, PRIMARY KEY (id), - CONSTRAINT x_role_ref_user_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_role_ref_user_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_role_ref_user_FK_role_id FOREIGN KEY (role_id) REFERENCES x_role (id), CONSTRAINT x_role_ref_user_FK_user_id FOREIGN KEY (user_id) REFERENCES x_user (id) ); @@ -1520,17 +1442,11 @@ commit; CREATE SEQUENCE x_role_ref_group_SEQ; CREATE TABLE x_role_ref_group( id BIGINT DEFAULT nextval('x_role_ref_group_SEQ'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, role_id BIGINT NOT NULL, group_id BIGINT DEFAULT NULL NULL, group_name varchar(767) DEFAULT NULL NULL, priv_type INT DEFAULT NULL NULL, PRIMARY KEY (id), - CONSTRAINT x_role_ref_grp_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_role_ref_grp_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_role_ref_grp_FK_role_id FOREIGN KEY (role_id) REFERENCES x_role (id), CONSTRAINT x_role_ref_grp_FK_group_id FOREIGN KEY (group_id) REFERENCES x_group (id) ); @@ -1539,17 +1455,11 @@ commit; CREATE SEQUENCE x_policy_ref_role_SEQ; CREATE TABLE x_policy_ref_role( id BIGINT DEFAULT nextval('x_policy_ref_role_SEQ'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, policy_id BIGINT NOT NULL, role_id BIGINT NOT NULL, role_name varchar(255) DEFAULT NULL, PRIMARY KEY (id), CONSTRAINT x_pol_ref_role_UK_polId_roleId UNIQUE(policy_id,role_id), - CONSTRAINT x_pol_ref_role_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_pol_ref_role_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_pol_ref_role_FK_policy_id FOREIGN KEY (policy_id) REFERENCES x_policy (id), CONSTRAINT x_pol_ref_role_FK_role_id FOREIGN KEY (role_id) REFERENCES x_role (id) ); @@ -1558,17 +1468,11 @@ commit; CREATE SEQUENCE x_role_ref_role_SEQ; CREATE TABLE x_role_ref_role( id BIGINT DEFAULT nextval('x_role_ref_role_SEQ'::regclass), -create_time TIMESTAMP DEFAULT NULL NULL, -update_time TIMESTAMP DEFAULT NULL NULL, -added_by_id BIGINT DEFAULT NULL NULL, -upd_by_id BIGINT DEFAULT NULL NULL, role_ref_id BIGINT DEFAULT NULL NULL, role_id BIGINT NOT NULL, role_name varchar(255) DEFAULT NULL NULL, priv_type INT DEFAULT NULL NULL, PRIMARY KEY (id), - CONSTRAINT x_role_ref_role_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES x_portal_user (id), - CONSTRAINT x_role_ref_role_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES x_portal_user (id), CONSTRAINT x_role_ref_role_FK_role_ref_id FOREIGN KEY (role_ref_id) REFERENCES x_role (id) ); commit; @@ -1896,6 +1800,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 ('058',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 ('059',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 ('060',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 ('061',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/061SKIP-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/postgres/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql new file mode 100644 index 0000000000..8dd1de6e5e --- /dev/null +++ b/security-admin/db/postgres/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql @@ -0,0 +1,99 @@ +-- 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. + +-- Commented because dropping this column would break high-availability setups +-- We can uncomment this after the next major version upgrade +/* +ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS guid CASCADE; +ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_resource DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_role DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS guid CASCADE; +ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_group DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS guid CASCADE; +ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_user DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS guid CASCADE; +ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_access_type DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS guid CASCADE; +ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_condition DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS guid CASCADE; +ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_policy_ref_datamask_type DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_security_zone_ref_service DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_security_zone_ref_service DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_security_zone_ref_service DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_security_zone_ref_service DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_security_zone_ref_tag_srvc DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_security_zone_ref_tag_srvc DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_security_zone_ref_tag_srvc DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_security_zone_ref_tag_srvc DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_security_zone_ref_user DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_security_zone_ref_user DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_security_zone_ref_user DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_security_zone_ref_user DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_security_zone_ref_group DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_security_zone_ref_group DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_security_zone_ref_group DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_security_zone_ref_group DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_security_zone_ref_resource DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_security_zone_ref_resource DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_security_zone_ref_resource DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_security_zone_ref_resource DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_role_ref_user DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_role_ref_user DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_role_ref_user DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_role_ref_user DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_role_ref_group DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_role_ref_group DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_role_ref_group DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_role_ref_group DROP COLUMN IF EXISTS upd_by_id CASCADE; + +ALTER TABLE x_role_ref_role DROP COLUMN IF EXISTS create_time CASCADE; +ALTER TABLE x_role_ref_role DROP COLUMN IF EXISTS update_time CASCADE; +ALTER TABLE x_role_ref_role DROP COLUMN IF EXISTS added_by_id CASCADE; +ALTER TABLE x_role_ref_role DROP COLUMN IF EXISTS upd_by_id CASCADE; +*/ 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 3ed2a5b9c5..e2f3a00d98 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 @@ -1080,11 +1080,6 @@ CREATE TABLE dbo.x_ugsync_audit_info( GO create table dbo.x_policy_ref_resource ( id bigint IDENTITY NOT NULL, - guid varchar(1024) DEFAULT NULL NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, resource_def_id bigint NOT NULL, resource_name varchar(4000) DEFAULT NULL NULL, @@ -1094,11 +1089,6 @@ create table dbo.x_policy_ref_resource ( GO create table dbo.x_policy_ref_access_type ( id bigint IDENTITY NOT NULL, - guid varchar(1024) DEFAULT NULL NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, access_def_id bigint NOT NULL, access_type_name varchar(4000) DEFAULT NULL NULL, @@ -1108,11 +1098,6 @@ create table dbo.x_policy_ref_access_type ( GO create table dbo.x_policy_ref_condition ( id bigint IDENTITY NOT NULL, - guid varchar(1024) DEFAULT NULL NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, condition_def_id bigint NOT NULL, condition_name varchar(4000) DEFAULT NULL NULL, @@ -1122,11 +1107,6 @@ create table dbo.x_policy_ref_condition ( GO create table dbo.x_policy_ref_datamask_type ( id bigint IDENTITY NOT NULL, - guid varchar(1024) DEFAULT NULL NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, datamask_def_id bigint NOT NULL, datamask_type_name varchar(4000) DEFAULT NULL NULL, @@ -1136,11 +1116,6 @@ create table dbo.x_policy_ref_datamask_type ( GO create table dbo.x_policy_ref_user ( id bigint IDENTITY NOT NULL, - guid varchar(1024) DEFAULT NULL NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, user_id bigint NOT NULL, user_name varchar(4000) DEFAULT NULL NULL, @@ -1150,11 +1125,6 @@ create table dbo.x_policy_ref_user ( GO create table dbo.x_policy_ref_group ( id bigint IDENTITY NOT NULL, - guid varchar(1024) DEFAULT NULL NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, group_id bigint NOT NULL, group_name varchar(4000) DEFAULT NULL NULL, @@ -1164,10 +1134,6 @@ create table dbo.x_policy_ref_group ( GO CREATE TABLE dbo.x_security_zone_ref_service( id bigint IDENTITY NOT NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, zone_id bigint DEFAULT NULL NULL, service_id bigint DEFAULT NULL NULL, service_name varchar(255) DEFAULT NULL NULL, @@ -1176,10 +1142,6 @@ CREATE TABLE dbo.x_security_zone_ref_service( GO CREATE TABLE dbo.x_security_zone_ref_tag_srvc( id bigint IDENTITY NOT NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, zone_id bigint DEFAULT NULL NULL, tag_srvc_id bigint DEFAULT NULL NULL, tag_srvc_name varchar(255) DEFAULT NULL NULL, @@ -1188,10 +1150,6 @@ CREATE TABLE dbo.x_security_zone_ref_tag_srvc( GO CREATE TABLE dbo.x_security_zone_ref_resource( id bigint IDENTITY NOT NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, zone_id bigint DEFAULT NULL NULL, resource_def_id bigint DEFAULT NULL NULL, resource_name varchar(255) DEFAULT NULL NULL, @@ -1200,10 +1158,6 @@ CREATE TABLE dbo.x_security_zone_ref_resource( GO CREATE TABLE dbo.x_security_zone_ref_user( id bigint IDENTITY NOT NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, zone_id bigint DEFAULT NULL NULL, user_id bigint DEFAULT NULL NULL, user_name varchar(767) DEFAULT NULL NULL, @@ -1213,10 +1167,6 @@ CREATE TABLE dbo.x_security_zone_ref_user( GO CREATE TABLE dbo.x_security_zone_ref_group( id bigint IDENTITY NOT NULL, - create_time datetime DEFAULT NULL NULL, - update_time datetime DEFAULT NULL NULL, - added_by_id bigint DEFAULT NULL NULL, - upd_by_id bigint DEFAULT NULL NULL, zone_id bigint DEFAULT NULL NULL, group_id bigint DEFAULT NULL NULL, group_name varchar(767) DEFAULT NULL NULL, @@ -1269,10 +1219,6 @@ GO CREATE TABLE dbo.x_role_ref_user( id bigint IDENTITY NOT NULL, -create_time datetime DEFAULT NULL NULL, -update_time datetime DEFAULT NULL NULL, -added_by_id bigint DEFAULT NULL NULL, -upd_by_id bigint DEFAULT NULL NULL, role_id bigint NOT NULL, user_id bigint DEFAULT NULL NULL, user_name varchar(767) DEFAULT NULL NULL, @@ -1283,10 +1229,6 @@ GO CREATE TABLE dbo.x_role_ref_group( id bigint IDENTITY NOT NULL, -create_time datetime DEFAULT NULL NULL, -update_time datetime DEFAULT NULL NULL, -added_by_id bigint DEFAULT NULL NULL, -upd_by_id bigint DEFAULT NULL NULL, role_id bigint NOT NULL, group_id bigint DEFAULT NULL NULL, group_name varchar(767) DEFAULT NULL NULL, @@ -1297,10 +1239,6 @@ GO CREATE TABLE dbo.x_policy_ref_role( id bigint IDENTITY NOT NULL, -create_time datetime DEFAULT NULL NULL, -update_time datetime DEFAULT NULL NULL, -added_by_id bigint DEFAULT NULL NULL, -upd_by_id bigint DEFAULT NULL NULL, policy_id bigint NOT NULL, role_id bigint NOT NULL, role_name varchar(255) DEFAULT NULL NULL, @@ -1311,10 +1249,6 @@ GO CREATE TABLE dbo.x_role_ref_role( id bigint IDENTITY NOT NULL, -create_time datetime DEFAULT NULL NULL, -update_time datetime DEFAULT NULL NULL, -added_by_id bigint DEFAULT NULL NULL, -upd_by_id bigint DEFAULT NULL NULL, role_ref_id bigint DEFAULT NULL NULL, role_id bigint NOT NULL, role_name varchar(255) DEFAULT NULL NULL, @@ -1609,50 +1543,26 @@ ALTER TABLE dbo.x_policy_ref_resource ADD CONSTRAINT x_policy_ref_resource_FK_po GO ALTER TABLE dbo.x_policy_ref_resource ADD CONSTRAINT x_policy_ref_resource_FK_resource_def_id FOREIGN KEY (resource_def_id) REFERENCES dbo.x_resource_def (id) GO -ALTER TABLE dbo.x_policy_ref_resource ADD CONSTRAINT x_policy_ref_resource_FK_added_by FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_resource ADD CONSTRAINT x_policy_ref_resource_FK_upd_by FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_policy_ref_access_type ADD CONSTRAINT x_policy_ref_access_type_FK_policy_id FOREIGN KEY (policy_id) REFERENCES dbo.x_policy (id) GO ALTER TABLE dbo.x_policy_ref_access_type ADD CONSTRAINT x_policy_ref_access_type_FK_access_def_id FOREIGN KEY (access_def_id) REFERENCES dbo.x_access_type_def (id) GO -ALTER TABLE dbo.x_policy_ref_access_type ADD CONSTRAINT x_policy_ref_access_type_FK_added_by FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_access_type ADD CONSTRAINT x_policy_ref_access_type_FK_upd_by FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_policy_ref_condition ADD CONSTRAINT x_policy_ref_condition_FK_policy_id FOREIGN KEY (policy_id) REFERENCES dbo.x_policy (id) GO ALTER TABLE dbo.x_policy_ref_condition ADD CONSTRAINT x_policy_ref_condition_FK_condition_def_id FOREIGN KEY (condition_def_id) REFERENCES dbo.x_policy_condition_def (id) GO -ALTER TABLE dbo.x_policy_ref_condition ADD CONSTRAINT x_policy_ref_condition_FK_added_by FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_condition ADD CONSTRAINT x_policy_ref_condition_FK_upd_by FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_policy_ref_datamask_type ADD CONSTRAINT x_policy_ref_datamask_type_FK_policy_id FOREIGN KEY (policy_id) REFERENCES dbo.x_policy (id) GO ALTER TABLE dbo.x_policy_ref_datamask_type ADD CONSTRAINT x_policy_ref_datamask_type_FK_datamask_def_id FOREIGN KEY (datamask_def_id) REFERENCES dbo.x_datamask_type_def (id) GO -ALTER TABLE dbo.x_policy_ref_datamask_type ADD CONSTRAINT x_policy_ref_datamask_type_FK_added_by FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_datamask_type ADD CONSTRAINT x_policy_ref_datamask_type_FK_upd_by FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_policy_ref_user ADD CONSTRAINT x_policy_ref_user_FK_policy_id FOREIGN KEY (policy_id) REFERENCES dbo.x_policy (id) GO ALTER TABLE dbo.x_policy_ref_user ADD CONSTRAINT x_policy_ref_user_FK_user_id FOREIGN KEY (user_id) REFERENCES dbo.x_user (id) GO -ALTER TABLE dbo.x_policy_ref_user ADD CONSTRAINT x_policy_ref_user_FK_added_by FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_user ADD CONSTRAINT x_policy_ref_user_FK_upd_by FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_policy_ref_group ADD CONSTRAINT x_policy_ref_group_FK_policy_id FOREIGN KEY (policy_id) REFERENCES dbo.x_policy (id) GO ALTER TABLE dbo.x_policy_ref_group ADD CONSTRAINT x_policy_ref_group_FK_group_id FOREIGN KEY (group_id) REFERENCES dbo.x_group (id) GO -ALTER TABLE dbo.x_policy_ref_group ADD CONSTRAINT x_policy_ref_group_FK_added_by FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_group ADD CONSTRAINT x_policy_ref_group_FK_upd_by FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_security_zone ADD CONSTRAINT x_security_zone_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES dbo.x_portal_user (id) GO ALTER TABLE dbo.x_security_zone ADD CONSTRAINT x_security_zone_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES dbo.x_portal_user (id) @@ -1663,79 +1573,43 @@ ALTER TABLE dbo.x_ranger_global_state ADD CONSTRAINT x_ranger_global_state_FK_up GO ALTER TABLE dbo.x_policy ADD CONSTRAINT x_policy_FK_zone_id FOREIGN KEY(zone_id) REFERENCES dbo.x_security_zone (id) GO -ALTER TABLE dbo.x_security_zone_ref_service ADD CONSTRAINT x_sz_ref_service_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_security_zone_ref_service ADD CONSTRAINT x_sz_ref_service_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_security_zone_ref_service ADD CONSTRAINT x_sz_ref_service_FK_zone_id FOREIGN KEY(zone_id) REFERENCES dbo.x_security_zone (id) GO ALTER TABLE dbo.x_security_zone_ref_service ADD CONSTRAINT x_sz_ref_service_FK_service_id FOREIGN KEY(service_id) REFERENCES dbo.x_service (id) GO ALTER TABLE dbo.x_security_zone_ref_service ADD CONSTRAINT x_sz_ref_service_FK_service_name FOREIGN KEY(service_name) REFERENCES dbo.x_service (name) GO -ALTER TABLE dbo.x_security_zone_ref_tag_srvc ADD CONSTRAINT x_sz_ref_tag_service_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_security_zone_ref_tag_srvc ADD CONSTRAINT x_sz_ref_tag_service_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_security_zone_ref_tag_srvc ADD CONSTRAINT x_sz_ref_tag_service_FK_zone_id FOREIGN KEY(zone_id) REFERENCES dbo.x_security_zone (id) GO ALTER TABLE dbo.x_security_zone_ref_tag_srvc ADD CONSTRAINT x_sz_ref_tag_service_FK_tag_service_id FOREIGN KEY(tag_service_id) REFERENCES dbo.x_service (id) GO ALTER TABLE dbo.x_security_zone_ref_tag_srvc ADD CONSTRAINT x_sz_ref_tag_service_FK_tag_service_name FOREIGN KEY(tag_service_name) REFERENCES dbo.x_service (name) GO -ALTER TABLE dbo.x_security_zone_ref_resource ADD CONSTRAINT x_sz_ref_resource_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_security_zone_ref_resource ADD CONSTRAINT x_sz_ref_resource_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_security_zone_ref_resource ADD CONSTRAINT x_sz_ref_resource_FK_zone_id FOREIGN KEY(zone_id) REFERENCES dbo.x_security_zone (id) GO ALTER TABLE dbo.x_security_zone_ref_resource ADD CONSTRAINT x_sz_ref_resource_FK_service_id FOREIGN KEY(resource_def_id) REFERENCES dbo.x_resource_def (id) GO -ALTER TABLE dbo.x_security_zone_ref_user ADD CONSTRAINT x_sz_ref_user_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_security_zone_ref_user ADD CONSTRAINT x_sz_ref_user_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_security_zone_ref_user ADD CONSTRAINT x_sz_ref_user_FK_zone_id FOREIGN KEY(zone_id) REFERENCES dbo.x_security_zone (id) GO ALTER TABLE dbo.x_security_zone_ref_user ADD CONSTRAINT x_sz_ref_user_FK_user_id FOREIGN KEY(user_id) REFERENCES dbo.x_user (id) GO ALTER TABLE dbo.x_security_zone_ref_user ADD CONSTRAINT x_sz_ref_user_FK_user_name FOREIGN KEY(user_name) REFERENCES dbo.x_user (user_name) GO -ALTER TABLE dbo.x_security_zone_ref_group ADD CONSTRAINT x_sz_ref_grp_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_security_zone_ref_group ADD CONSTRAINT x_sz_ref_grp_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_security_zone_ref_group ADD CONSTRAINT x_sz_ref_grp_FK_zone_id FOREIGN KEY(zone_id) REFERENCES dbo.x_security_zone (id) GO ALTER TABLE dbo.x_security_zone_ref_group ADD CONSTRAINT x_sz_ref_grp_FK_group_id FOREIGN KEY(group_id) REFERENCES dbo.x_group (id) GO -ALTER TABLE dbo.x_role_ref_role ADD CONSTRAINT x_role_ref_role_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_role_ref_role ADD CONSTRAINT x_role_ref_role_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_role_ref_role ADD CONSTRAINT x_role_ref_role_FK_role_ref_id FOREIGN KEY (role_ref_id) REFERENCES dbo.x_role (id) GO -ALTER TABLE dbo.x_policy_ref_role ADD CONSTRAINT x_pol_ref_role_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_policy_ref_role ADD CONSTRAINT x_pol_ref_role_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_policy_ref_role ADD CONSTRAINT x_pol_ref_role_FK_policy_id FOREIGN KEY (policy_id) REFERENCES dbo.x_policy (id) GO ALTER TABLE dbo.x_policy_ref_role ADD CONSTRAINT x_pol_ref_role_FK_role_id FOREIGN KEY (role_id) REFERENCES dbo.x_role (id) GO -ALTER TABLE dbo.x_role_ref_group ADD CONSTRAINT x_role_ref_grp_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_role_ref_group ADD CONSTRAINT x_role_ref_grp_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_role_ref_group ADD CONSTRAINT x_role_ref_grp_FK_role_id FOREIGN KEY (role_id) REFERENCES dbo.x_role (id) GO ALTER TABLE dbo.x_role_ref_group ADD CONSTRAINT x_role_ref_grp_FK_group_id FOREIGN KEY (group_id) REFERENCES dbo.x_group (id) GO -ALTER TABLE dbo.x_role_ref_user ADD CONSTRAINT x_role_ref_user_FK_added_by_id FOREIGN KEY (added_by_id) REFERENCES dbo.x_portal_user (id) -GO -ALTER TABLE dbo.x_role_ref_user ADD CONSTRAINT x_role_ref_user_FK_upd_by_id FOREIGN KEY (upd_by_id) REFERENCES dbo.x_portal_user (id) -GO ALTER TABLE dbo.x_role_ref_user ADD CONSTRAINT x_role_ref_user_FK_role_id FOREIGN KEY (role_id) REFERENCES dbo.x_role (id) GO ALTER TABLE dbo.x_role_ref_user ADD CONSTRAINT x_role_ref_user_FK_user_id FOREIGN KEY (user_id) REFERENCES dbo.x_user (id) @@ -2267,6 +2141,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 ('060',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 ('061',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/061SKIP-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/sqlanywhere/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql new file mode 100644 index 0000000000..4cb26ba89a --- /dev/null +++ b/security-admin/db/sqlanywhere/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql @@ -0,0 +1,249 @@ +-- 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. + +-- Commented because dropping this column would break high-availability setups +-- We can uncomment this after the next major version upgrade +/* +CREATE OR REPLACE PROCEDURE dbo.dropTableColumn (@table_name varchar(100), @column_name varchar(100)) +AS +BEGIN + DECLARE @stmt VARCHAR(300) + IF EXISTS(select * from SYS.SYSCOLUMNS where tname = @table_name and cname = @column_name) + BEGIN + SET @stmt = 'ALTER TABLE dbo.' + @table_name + ' DROP ' + @column_name; + execute(@stmt) + END +END +GO + +CREATE OR REPLACE PROCEDURE dbo.dropTableConstraint (@table_name varchar(100), @constraint_name varchar(100)) +AS +BEGIN + DECLARE @stmt VARCHAR(300) + IF EXISTS(select * from SYS.SYSCONSTRAINT where constraint_name = @constraint_name) + BEGIN + SET @stmt = 'ALTER TABLE dbo.' + @table_name + ' DROP CONSTRAINT ' + @constraint_name; + execute(@stmt) + END +END +GO + +call dbo.dropTableColumn('x_policy_ref_resource', 'guid') +GO +call dbo.dropTableColumn('x_policy_ref_resource', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_resource', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_resource', 'x_policy_ref_resource_FK_added_by') +GO +call dbo.dropTableColumn('x_policy_ref_resource', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_resource', 'x_policy_ref_resource_FK_upd_by') +GO +call dbo.dropTableColumn('x_policy_ref_resource', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_policy_ref_role', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_role', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_role', 'x_pol_ref_role_FK_added_by_id') +GO +call dbo.dropTableColumn('x_policy_ref_role', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_role', 'x_pol_ref_role_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_policy_ref_role', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_policy_ref_group', 'guid') +GO +call dbo.dropTableColumn('x_policy_ref_group', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_group', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_group', 'x_policy_ref_group_FK_added_by') +GO +call dbo.dropTableColumn('x_policy_ref_group', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_group', 'x_policy_ref_group_FK_upd_by') +GO +call dbo.dropTableColumn('x_policy_ref_group', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_policy_ref_user', 'guid') +GO +call dbo.dropTableColumn('x_policy_ref_user', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_user', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_user', 'x_policy_ref_user_FK_added_by') +GO +call dbo.dropTableColumn('x_policy_ref_user', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_user', 'x_policy_ref_user_FK_upd_by') +GO +call dbo.dropTableColumn('x_policy_ref_user', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_policy_ref_access_type', 'guid') +GO +call dbo.dropTableColumn('x_policy_ref_access_type', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_access_type', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_access_type', 'x_policy_ref_access_type_FK_added_by') +GO +call dbo.dropTableColumn('x_policy_ref_access_type', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_access_type', 'x_policy_ref_access_type_FK_upd_by') +GO +call dbo.dropTableColumn('x_policy_ref_access_type', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_policy_ref_condition', 'guid') +GO +call dbo.dropTableColumn('x_policy_ref_condition', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_condition', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_condition', 'x_policy_ref_condition_FK_added_by') +GO +call dbo.dropTableColumn('x_policy_ref_condition', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_condition', 'x_policy_ref_condition_FK_upd_by') +GO +call dbo.dropTableColumn('x_policy_ref_condition', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_policy_ref_datamask_type', 'guid') +GO +call dbo.dropTableColumn('x_policy_ref_datamask_type', 'create_time') +GO +call dbo.dropTableColumn('x_policy_ref_datamask_type', 'update_time') +GO +call dbo.dropTableConstraint('x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_added_by') +GO +call dbo.dropTableColumn('x_policy_ref_datamask_type', 'added_by_id') +GO +call dbo.dropTableConstraint('x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_upd_by') +GO +call dbo.dropTableColumn('x_policy_ref_datamask_type', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_security_zone_ref_service', 'create_time') +GO +call dbo.dropTableColumn('x_security_zone_ref_service', 'update_time') +GO +call dbo.dropTableConstraint('x_security_zone_ref_service', 'x_sz_ref_service_FK_added_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_service', 'added_by_id') +GO +call dbo.dropTableConstraint('x_security_zone_ref_service', 'x_sz_ref_service_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_service', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_security_zone_ref_tag_srvc', 'create_time') +GO +call dbo.dropTableColumn('x_security_zone_ref_tag_srvc', 'update_time') +GO +call dbo.dropTableConstraint('x_security_zone_ref_tag_srvc', 'x_sz_ref_tag_service_FK_added_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_tag_srvc', 'added_by_id') +GO +call dbo.dropTableConstraint('x_security_zone_ref_tag_srvc', 'x_sz_ref_tag_service_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_tag_srvc', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_security_zone_ref_user', 'create_time') +GO +call dbo.dropTableColumn('x_security_zone_ref_user', 'update_time') +GO +call dbo.dropTableConstraint('x_security_zone_ref_user', 'x_sz_ref_user_FK_added_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_user', 'added_by_id') +GO +call dbo.dropTableConstraint('x_security_zone_ref_user', 'x_sz_ref_user_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_user', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_security_zone_ref_group', 'create_time') +GO +call dbo.dropTableColumn('x_security_zone_ref_group', 'update_time') +GO +call dbo.dropTableConstraint('x_security_zone_ref_group', 'x_sz_ref_grp_FK_added_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_group', 'added_by_id') +GO +call dbo.dropTableConstraint('x_security_zone_ref_group', 'x_sz_ref_grp_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_group', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_security_zone_ref_resource', 'create_time') +GO +call dbo.dropTableColumn('x_security_zone_ref_resource', 'update_time') +GO +call dbo.dropTableConstraint('x_security_zone_ref_resource', 'x_sz_ref_resource_FK_added_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_resource', 'added_by_id') +GO +call dbo.dropTableConstraint('x_security_zone_ref_resource', 'x_sz_ref_resource_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_security_zone_ref_resource', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_role_ref_user', 'create_time') +GO +call dbo.dropTableColumn('x_role_ref_user', 'update_time') +GO +call dbo.dropTableConstraint('x_role_ref_user', 'x_role_ref_user_FK_added_by_id') +GO +call dbo.dropTableColumn('x_role_ref_user', 'added_by_id') +GO +call dbo.dropTableConstraint('x_role_ref_user', 'x_role_ref_user_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_role_ref_user', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_role_ref_group', 'create_time') +GO +call dbo.dropTableColumn('x_role_ref_group', 'update_time') +GO +call dbo.dropTableConstraint('x_role_ref_group', 'x_role_ref_grp_FK_added_by_id') +GO +call dbo.dropTableColumn('x_role_ref_group', 'added_by_id') +GO +call dbo.dropTableConstraint('x_role_ref_group', 'x_role_ref_grp_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_role_ref_group', 'upd_by_id') +GO + +call dbo.dropTableColumn('x_role_ref_role', 'create_time') +GO +call dbo.dropTableColumn('x_role_ref_role', 'update_time') +GO +call dbo.dropTableConstraint('x_role_ref_role', 'x_role_ref_role_FK_added_by_id') +GO +call dbo.dropTableColumn('x_role_ref_role', 'added_by_id') +GO +call dbo.dropTableConstraint('x_role_ref_role', 'x_role_ref_role_FK_upd_by_id') +GO +call dbo.dropTableColumn('x_role_ref_role', 'upd_by_id') +GO +*/ 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 ca8f7da1f8..6496b4b99f 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 @@ -2154,11 +2154,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_resource] ( [id] [bigint] IDENTITY (1, 1) NOT NULL, - [guid] [varchar](1024) DEFAULT NULL NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [resource_def_id] [bigint] NOT NULL, [resource_name] [varchar](4000) DEFAULT NULL NULL, @@ -2176,11 +2171,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_access_type] ( [id] [bigint] IDENTITY (1, 1) NOT NULL, - [guid] [varchar](1024) DEFAULT NULL NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [access_def_id] [bigint] NOT NULL, [access_type_name] [varchar](4000) DEFAULT NULL NULL, @@ -2198,11 +2188,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_condition] ( [id] [bigint] IDENTITY (1, 1) NOT NULL, - [guid] [varchar](1024) DEFAULT NULL NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [condition_def_id] [bigint] NOT NULL, [condition_name] [varchar](4000) DEFAULT NULL NULL, @@ -2220,11 +2205,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_datamask_type] ( [id] [bigint] IDENTITY (1, 1) NOT NULL, - [guid] [varchar](1024) DEFAULT NULL NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [datamask_def_id] [bigint] NOT NULL, [datamask_type_name] [varchar](4000) DEFAULT NULL NULL, @@ -2242,11 +2222,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_user] ( [id] [bigint] IDENTITY (1, 1) NOT NULL, - [guid] [varchar](1024) DEFAULT NULL NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [user_id] [bigint] NOT NULL, [user_name] [nvarchar](4000) DEFAULT NULL NULL, @@ -2264,11 +2239,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_group] ( [id] [bigint] IDENTITY (1, 1) NOT NULL, - [guid] [varchar](1024) DEFAULT NULL NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [group_id] [bigint] NOT NULL, [group_name] [nvarchar](4000) DEFAULT NULL NULL, @@ -2286,10 +2256,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_security_zone_ref_service]( [id] [bigint] IDENTITY(1,1) NOT NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [zone_id] [bigint] DEFAULT NULL NULL, [service_id] [bigint] DEFAULT NULL NULL, [service_name] [varchar](255) DEFAULT NULL NULL, @@ -2299,10 +2265,6 @@ CREATE TABLE [dbo].[x_security_zone_ref_service]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_security_zone_ref_service] WITH CHECK ADD CONSTRAINT [x_sz_ref_service_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_security_zone_ref_service] WITH CHECK ADD CONSTRAINT [x_sz_ref_service_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_security_zone_ref_service] WITH CHECK ADD CONSTRAINT [x_sz_ref_service_FK_zone_id] FOREIGN KEY([zone_id]) REFERENCES [dbo].[x_security_zone] ([id]) GO ALTER TABLE [dbo].[x_security_zone_ref_service] WITH CHECK ADD CONSTRAINT [x_sz_ref_service_FK_service_id] FOREIGN KEY([service_id]) REFERENCES [dbo].[x_service] ([id]) @@ -2311,10 +2273,6 @@ ALTER TABLE [dbo].[x_security_zone_ref_service] WITH CHECK ADD CONSTRAINT [x_sz_ GO CREATE TABLE [dbo].[x_security_zone_ref_tag_srvc]( [id] [bigint] IDENTITY(1,1) NOT NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [zone_id] [bigint] DEFAULT NULL NULL, [tag_srvc_id] [bigint] DEFAULT NULL NULL, [tag_srvc_name] [varchar](255) DEFAULT NULL NULL, @@ -2324,10 +2282,6 @@ CREATE TABLE [dbo].[x_security_zone_ref_tag_srvc]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_security_zone_ref_tag_srvc] WITH CHECK ADD CONSTRAINT [x_sz_ref_tag_service_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_security_zone_ref_tag_srvc] WITH CHECK ADD CONSTRAINT [x_sz_ref_tag_service_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_security_zone_ref_tag_srvc] WITH CHECK ADD CONSTRAINT [x_sz_ref_tag_service_FK_zone_id] FOREIGN KEY([zone_id]) REFERENCES [dbo].[x_security_zone] ([id]) GO ALTER TABLE [dbo].[x_security_zone_ref_tag_srvc] WITH CHECK ADD CONSTRAINT [x_sz_ref_tag_service_FK_tag_srvc_id] FOREIGN KEY([tag_srvc_id]) REFERENCES [dbo].[x_service] ([id]) @@ -2339,10 +2293,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_security_zone_ref_resource]( [id] [bigint] IDENTITY(1,1) NOT NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [zone_id] [bigint] DEFAULT NULL NULL, [resource_def_id] [bigint] DEFAULT NULL NULL, [resource_name] [varchar](255) DEFAULT NULL NULL, @@ -2352,10 +2302,6 @@ CREATE TABLE [dbo].[x_security_zone_ref_resource]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_security_zone_ref_resource] WITH CHECK ADD CONSTRAINT [x_sz_ref_resource_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_security_zone_ref_resource] WITH CHECK ADD CONSTRAINT [x_sz_ref_resource_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_security_zone_ref_resource] WITH CHECK ADD CONSTRAINT [x_sz_ref_resource_FK_zone_id] FOREIGN KEY([zone_id]) REFERENCES [dbo].[x_security_zone] ([id]) GO ALTER TABLE [dbo].[x_security_zone_ref_resource] WITH CHECK ADD CONSTRAINT [x_sz_ref_resource_FK_resource_def_id] FOREIGN KEY([resource_def_id]) REFERENCES [dbo].[x_resource_def] ([id]) @@ -2365,10 +2311,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_security_zone_ref_user]( [id] [bigint] IDENTITY(1,1) NOT NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [zone_id] [bigint] DEFAULT NULL NULL, [user_id] [bigint] DEFAULT NULL NULL, [user_name] [nvarchar](767) DEFAULT NULL NULL, @@ -2379,10 +2321,6 @@ CREATE TABLE [dbo].[x_security_zone_ref_user]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_security_zone_ref_user] WITH CHECK ADD CONSTRAINT [x_sz_ref_user_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_security_zone_ref_user] WITH CHECK ADD CONSTRAINT [x_sz_ref_user_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_security_zone_ref_user] WITH CHECK ADD CONSTRAINT [x_sz_ref_user_FK_zone_id] FOREIGN KEY([zone_id]) REFERENCES [dbo].[x_security_zone] ([id]) GO ALTER TABLE [dbo].[x_security_zone_ref_user] WITH CHECK ADD CONSTRAINT [x_sz_ref_user_FK_user_id] FOREIGN KEY([user_id]) REFERENCES [dbo].[x_user] ([id]) @@ -2394,10 +2332,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_security_zone_ref_group]( [id] [bigint] IDENTITY(1,1) NOT NULL, - [create_time] [datetime2] DEFAULT NULL NULL, - [update_time] [datetime2] DEFAULT NULL NULL, - [added_by_id] [bigint] DEFAULT NULL NULL, - [upd_by_id] [bigint] DEFAULT NULL NULL, [zone_id] [bigint] DEFAULT NULL NULL, [group_id] [bigint] DEFAULT NULL NULL, [group_name] [nvarchar](767) DEFAULT NULL NULL, @@ -2408,10 +2342,6 @@ CREATE TABLE [dbo].[x_security_zone_ref_group]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_security_zone_ref_group] WITH CHECK ADD CONSTRAINT [x_sz_ref_group_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_security_zone_ref_group] WITH CHECK ADD CONSTRAINT [x_sz_ref_group_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_security_zone_ref_group] WITH CHECK ADD CONSTRAINT [x_sz_ref_group_FK_zone_id] FOREIGN KEY([zone_id]) REFERENCES [dbo].[x_security_zone] ([id]) GO ALTER TABLE [dbo].[x_security_zone_ref_group] WITH CHECK ADD CONSTRAINT [x_sz_ref_group_FK_group_id] FOREIGN KEY([group_id]) REFERENCES [dbo].[x_group] ([id]) @@ -2489,10 +2419,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_role_ref_user]( [id] [bigint] IDENTITY(1,1) NOT NULL, -[create_time] [datetime2] DEFAULT NULL NULL, -[update_time] [datetime2] DEFAULT NULL NULL, -[added_by_id] [bigint] DEFAULT NULL NULL, -[upd_by_id] [bigint] DEFAULT NULL NULL, [role_id] [bigint] NOT NULL, [user_id] [bigint] DEFAULT NULL NULL, [user_name] [nvarchar](767) DEFAULT NULL NULL, @@ -2503,10 +2429,6 @@ CREATE TABLE [dbo].[x_role_ref_user]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_role_ref_user] WITH CHECK ADD CONSTRAINT [x_role_ref_user_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_role_ref_user] WITH CHECK ADD CONSTRAINT [x_role_ref_user_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_role_ref_user] WITH CHECK ADD CONSTRAINT [x_role_ref_user_FK_role_id] FOREIGN KEY([role_id]) REFERENCES [dbo].[x_role] ([id]) GO ALTER TABLE [dbo].[x_role_ref_user] WITH CHECK ADD CONSTRAINT [x_role_ref_user_FK_user_id] FOREIGN KEY([user_id]) REFERENCES [dbo].[x_user] ([id]) @@ -2517,10 +2439,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_role_ref_group]( [id] [bigint] IDENTITY(1,1) NOT NULL, -[create_time] [datetime2] DEFAULT NULL NULL, -[update_time] [datetime2] DEFAULT NULL NULL, -[added_by_id] [bigint] DEFAULT NULL NULL, -[upd_by_id] [bigint] DEFAULT NULL NULL, [role_id] [bigint] NOT NULL, [group_id] [bigint] DEFAULT NULL NULL, [group_name] [nvarchar](767) DEFAULT NULL NULL, @@ -2531,10 +2449,6 @@ CREATE TABLE [dbo].[x_role_ref_group]( )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_role_ref_group] WITH CHECK ADD CONSTRAINT [x_role_ref_group_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_role_ref_group] WITH CHECK ADD CONSTRAINT [x_role_ref_group_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_role_ref_group] WITH CHECK ADD CONSTRAINT [x_role_ref_group_FK_role_id] FOREIGN KEY([role_id]) REFERENCES [dbo].[x_role] ([id]) GO ALTER TABLE [dbo].[x_role_ref_group] WITH CHECK ADD CONSTRAINT [x_role_ref_group_FK_group_id] FOREIGN KEY([group_id]) REFERENCES [dbo].[x_group] ([id]) @@ -2545,10 +2459,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_policy_ref_role]( [id] [bigint] IDENTITY(1,1) NOT NULL, -[create_time] [datetime2] DEFAULT NULL NULL, -[update_time] [datetime2] DEFAULT NULL NULL, -[added_by_id] [bigint] DEFAULT NULL NULL, -[upd_by_id] [bigint] DEFAULT NULL NULL, [policy_id] [bigint] NOT NULL, [role_id] [bigint] NOT NULL, [role_name] [nvarchar](255) DEFAULT NULL NULL, @@ -2562,10 +2472,6 @@ CREATE TABLE [dbo].[x_policy_ref_role]( )WITH (PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] GO -ALTER TABLE [dbo].[x_policy_ref_role] WITH CHECK ADD CONSTRAINT [x_policy_ref_role_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_policy_ref_role] WITH CHECK ADD CONSTRAINT [x_policy_ref_role_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_policy_ref_role] WITH CHECK ADD CONSTRAINT [x_policy_ref_role_FK_policy_id] FOREIGN KEY([policy_id]) REFERENCES [dbo].[x_policy] ([id]) GO ALTER TABLE [dbo].[x_policy_ref_role] WITH CHECK ADD CONSTRAINT [x_policy_ref_role_FK_role_id] FOREIGN KEY([role_id]) REFERENCES [dbo].[x_role] ([id]) @@ -2576,10 +2482,6 @@ SET QUOTED_IDENTIFIER ON SET ANSI_PADDING ON CREATE TABLE [dbo].[x_role_ref_role]( [id] [bigint] IDENTITY(1,1) NOT NULL, -[create_time] [datetime2] DEFAULT NULL NULL, -[update_time] [datetime2] DEFAULT NULL NULL, -[added_by_id] [bigint] DEFAULT NULL NULL, -[upd_by_id] [bigint] DEFAULT NULL NULL, [role_ref_id] [bigint] DEFAULT NULL NULL, [role_id] [bigint] NOT NULL, [role_name] [nvarchar](255) DEFAULT NULL NULL, @@ -2590,10 +2492,6 @@ CREATE TABLE [dbo].[x_role_ref_role]( ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] )ON [PRIMARY] GO -ALTER TABLE [dbo].[x_role_ref_role] WITH CHECK ADD CONSTRAINT [x_role_ref_role_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO -ALTER TABLE [dbo].[x_role_ref_role] WITH CHECK ADD CONSTRAINT [x_role_ref_role_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) -GO ALTER TABLE [dbo].[x_role_ref_role] WITH CHECK ADD CONSTRAINT [x_role_ref_role_FK_role_ref_id] FOREIGN KEY([role_ref_id]) REFERENCES [dbo].[x_role] ([id]) GO @@ -2996,44 +2894,24 @@ ALTER TABLE [dbo].[x_policy_ref_resource] CHECK CONSTRAINT [x_policy_ref_resourc ALTER TABLE [dbo].[x_policy_ref_resource] WITH CHECK ADD CONSTRAINT [x_policy_ref_resource_FK_res_def_id] FOREIGN KEY ([resource_def_id]) REFERENCES [dbo].[x_resource_def] ([id]) ALTER TABLE [dbo].[x_policy_ref_resource] CHECK CONSTRAINT [x_policy_ref_resource_FK_res_def_id] -ALTER TABLE [dbo].[x_policy_ref_resource] WITH CHECK ADD CONSTRAINT [x_policy_ref_resource_FK_added_by] FOREIGN KEY ([added_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_resource] CHECK CONSTRAINT [x_policy_ref_resource_FK_added_by] -ALTER TABLE [dbo].[x_policy_ref_resource] WITH CHECK ADD CONSTRAINT [x_policy_ref_resource_FK_upd_by] FOREIGN KEY ([upd_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_policy_ref_access_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_access_type_FK_policy_id] FOREIGN KEY ([policy_id]) REFERENCES [dbo].[x_policy] ([id]) ALTER TABLE [dbo].[x_policy_ref_access_type] CHECK CONSTRAINT [x_policy_ref_access_type_FK_policy_id] ALTER TABLE [dbo].[x_policy_ref_access_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_access_type_FK_access_def_id] FOREIGN KEY ([access_def_id]) REFERENCES [dbo].[x_access_type_def] ([id]) ALTER TABLE [dbo].[x_policy_ref_access_type] CHECK CONSTRAINT [x_policy_ref_access_type_FK_access_def_id] -ALTER TABLE [dbo].[x_policy_ref_access_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_access_type_FK_added_by] FOREIGN KEY ([added_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_access_type] CHECK CONSTRAINT [x_policy_ref_access_type_FK_added_by] -ALTER TABLE [dbo].[x_policy_ref_access_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_access_type_FK_upd_by] FOREIGN KEY ([upd_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_policy_ref_condition] WITH CHECK ADD CONSTRAINT [x_policy_ref_condition_FK_policy_id] FOREIGN KEY ([policy_id]) REFERENCES [dbo].[x_policy] ([id]) ALTER TABLE [dbo].[x_policy_ref_condition] CHECK CONSTRAINT [x_policy_ref_condition_FK_policy_id] ALTER TABLE [dbo].[x_policy_ref_condition] WITH CHECK ADD CONSTRAINT [x_policy_ref_condition_FK_res_def_id] FOREIGN KEY ([condition_def_id]) REFERENCES [dbo].[x_policy_condition_def] ([id]) ALTER TABLE [dbo].[x_policy_ref_condition] CHECK CONSTRAINT [x_policy_ref_condition_FK_res_def_id] -ALTER TABLE [dbo].[x_policy_ref_condition] WITH CHECK ADD CONSTRAINT [x_policy_ref_condition_FK_added_by] FOREIGN KEY ([added_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_condition] CHECK CONSTRAINT [x_policy_ref_condition_FK_added_by] -ALTER TABLE [dbo].[x_policy_ref_condition] WITH CHECK ADD CONSTRAINT [x_policy_ref_condition_FK_upd_by] FOREIGN KEY ([upd_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_policy_ref_datamask_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_datamask_type_FK_policy_id] FOREIGN KEY ([policy_id]) REFERENCES [dbo].[x_policy] ([id]) ALTER TABLE [dbo].[x_policy_ref_datamask_type] CHECK CONSTRAINT [x_policy_ref_datamask_type_FK_policy_id] ALTER TABLE [dbo].[x_policy_ref_datamask_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_datamask_type_FK_res_def_id] FOREIGN KEY ([datamask_def_id]) REFERENCES [dbo].[x_datamask_type_def] ([id]) ALTER TABLE [dbo].[x_policy_ref_datamask_type] CHECK CONSTRAINT [x_policy_ref_datamask_type_FK_res_def_id] -ALTER TABLE [dbo].[x_policy_ref_datamask_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_datamask_type_FK_added_by] FOREIGN KEY ([added_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_datamask_type] CHECK CONSTRAINT [x_policy_ref_datamask_type_FK_added_by] -ALTER TABLE [dbo].[x_policy_ref_datamask_type] WITH CHECK ADD CONSTRAINT [x_policy_ref_datamask_type_FK_upd_by] FOREIGN KEY ([upd_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_policy_ref_user] WITH CHECK ADD CONSTRAINT [x_policy_ref_user_FK_policy_id] FOREIGN KEY ([policy_id]) REFERENCES [dbo].[x_policy] ([id]) @@ -3043,25 +2921,12 @@ ALTER TABLE [dbo].[x_policy_ref_user] WITH CHECK ADD CONSTRAINT [x_policy_ref_us REFERENCES [dbo].[x_user] ([id]) ALTER TABLE [dbo].[x_policy_ref_user] CHECK CONSTRAINT [x_policy_ref_user_FK_user_id] -ALTER TABLE [dbo].[x_policy_ref_user] WITH CHECK ADD CONSTRAINT [x_policy_ref_user_FK_added_by] FOREIGN KEY ([added_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_user] CHECK CONSTRAINT [x_policy_ref_user_FK_added_by] - -ALTER TABLE [dbo].[x_policy_ref_user] WITH CHECK ADD CONSTRAINT [x_policy_ref_user_FK_upd_by] FOREIGN KEY ([upd_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_user] CHECK CONSTRAINT [x_policy_ref_user_FK_upd_by] - ALTER TABLE [dbo].[x_policy_ref_group] WITH CHECK ADD CONSTRAINT [x_policy_ref_group_FK_policy_id] FOREIGN KEY ([policy_id]) REFERENCES [dbo].[x_policy] ([id]) ALTER TABLE [dbo].[x_policy_ref_group] CHECK CONSTRAINT [x_policy_ref_group_FK_policy_id] ALTER TABLE [dbo].[x_policy_ref_group] WITH CHECK ADD CONSTRAINT [x_policy_ref_group_FK_group_id] FOREIGN KEY ([group_id]) REFERENCES [dbo].[x_group] ([id]) ALTER TABLE [dbo].[x_policy_ref_group] CHECK CONSTRAINT [x_policy_ref_group_FK_group_id] -ALTER TABLE [dbo].[x_policy_ref_group] WITH CHECK ADD CONSTRAINT [x_policy_ref_group_FK_added_by] FOREIGN KEY ([added_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) -ALTER TABLE [dbo].[x_policy_ref_group] CHECK CONSTRAINT [x_policy_ref_group_FK_added_by] -ALTER TABLE [dbo].[x_policy_ref_group] WITH CHECK ADD CONSTRAINT [x_policy_ref_group_FK_upd_by] FOREIGN KEY ([upd_by_id]) -REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_security_zone] WITH CHECK ADD CONSTRAINT [x_security_zone_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_security_zone] WITH CHECK ADD CONSTRAINT [x_security_zone_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) ALTER TABLE [dbo].[x_ranger_global_state] WITH CHECK ADD CONSTRAINT [x_ranger_global_state_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id]) @@ -4115,6 +3980,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 ('058',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 ('059',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 ('060',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 ('061',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/061SKIP-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/sqlserver/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql new file mode 100644 index 0000000000..3bac7fd6ad --- /dev/null +++ b/security-admin/db/sqlserver/patches/061SKIP-drop-audit-columns-from-policy-ref-tables.sql @@ -0,0 +1,317 @@ +-- 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. + +-- Commented because dropping this column would break high-availability setups +-- We can uncomment this after the next major version upgrade +/* +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 = 'dropTableColumn' + AND type = 'P' + ) +BEGIN + PRINT 'Proc exist with name dbo.dropTableColumn' + DROP PROCEDURE dbo.dropTableColumn + PRINT 'Proc dropped dbo.dropTableColumn' +END +GO +CREATE PROCEDURE dbo.dropTableColumn + -- Add the parameters for the stored procedure here + @tablename nvarchar(100), + @columnname nvarchar(100) +AS +BEGIN + IF EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = @tablename and column_name = @columnname) + BEGIN + DECLARE @stmt VARCHAR(300); + SET @stmt = 'ALTER TABLE [dbo].[' + @tablename + '] DROP COLUMN [' + @columnname + ']' + EXEC (@stmt); + END +END +GO + +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 = 'dropTableConstraint' + AND type = 'P' + ) +BEGIN + PRINT 'Proc exist with name dbo.dropTableConstraint' + DROP PROCEDURE dbo.dropTableConstraint + PRINT 'Proc dropped dbo.dropTableConstraint' +END +GO +CREATE PROCEDURE dbo.dropTableConstraint + -- Add the parameters for the stored procedure here + @tablename nvarchar(100), + @constraintname nvarchar(100) +AS +BEGIN + IF (OBJECT_ID(@constraintname) IS NOT NULL) + BEGIN + DECLARE @stmt VARCHAR(300); + SET @stmt = 'ALTER TABLE [dbo].[' + @tablename + '] DROP CONSTRAINT ' + @constraintname + EXEC (@stmt); + END +END +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'guid' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_resource', 'x_policy_ref_resource_FK_added_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_resource', 'x_policy_ref_resource_FK_upd_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_role', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_role', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_role', 'x_policy_ref_role_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_role', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_role', 'x_policy_ref_role_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_role', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_group', 'guid' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_group', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_group', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_group', 'x_policy_ref_group_FK_added_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_group', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_group', 'x_policy_ref_group_FK_upd_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_group', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_user', 'guid' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_user', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_user', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_user', 'x_policy_ref_user_FK_added_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_user', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_user', 'x_policy_ref_user_FK_upd_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_user', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'guid' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_access_type', 'x_policy_ref_access_type_FK_added_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_access_type', 'x_policy_ref_access_type_FK_upd_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'guid' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_condition', 'x_policy_ref_condition_FK_added_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_condition', 'x_policy_ref_condition_FK_upd_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'guid' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_added_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_upd_by' +GO +EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_security_zone_ref_service', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_service', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_service', 'x_sz_ref_service_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_service', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_service', 'x_sz_ref_service_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_service', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_security_zone_ref_tag_srvc', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_tag_srvc', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_tag_srvc', 'x_sz_ref_tag_service_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_tag_srvc', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_tag_srvc', 'x_sz_ref_tag_service_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_tag_srvc', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_security_zone_ref_user', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_user', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_user', 'x_sz_ref_user_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_user', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_user', 'x_sz_ref_user_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_user', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_security_zone_ref_group', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_group', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_group', 'x_sz_ref_group_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_group', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_group', 'x_sz_ref_group_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_group', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_security_zone_ref_resource', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_resource', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_resource', 'x_sz_ref_resource_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_resource', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_security_zone_ref_resource', 'x_sz_ref_resource_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_security_zone_ref_resource', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_role_ref_user', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_role_ref_user', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_role_ref_user', 'x_role_ref_user_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_role_ref_user', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_role_ref_user', 'x_role_ref_user_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_role_ref_user', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_role_ref_group', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_role_ref_group', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_role_ref_group', 'x_role_ref_group_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_role_ref_group', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_role_ref_group', 'x_role_ref_group_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_role_ref_group', 'upd_by_id' +GO + +EXEC dbo.dropTableColumn 'x_role_ref_role', 'create_time' +GO +EXEC dbo.dropTableColumn 'x_role_ref_role', 'update_time' +GO +EXEC dbo.dropTableConstraint 'x_role_ref_role', 'x_role_ref_role_FK_added_by_id' +GO +EXEC dbo.dropTableColumn 'x_role_ref_role', 'added_by_id' +GO +EXEC dbo.dropTableConstraint 'x_role_ref_role', 'x_role_ref_role_FK_upd_by_id' +GO +EXEC dbo.dropTableColumn 'x_role_ref_role', 'upd_by_id' +GO + +IF EXISTS ( + SELECT type_desc, type + FROM sys.procedures WITH(NOLOCK) + WHERE NAME = 'dropTableColumn' + AND type = 'P' + ) +BEGIN + PRINT 'Proc exist with name dbo.dropTableColumn' + DROP PROCEDURE dbo.dropTableColumn + PRINT 'Proc dropped dbo.dropTableColumn' +END +GO + +IF EXISTS ( + SELECT type_desc, type + FROM sys.procedures WITH(NOLOCK) + WHERE NAME = 'dropTableConstraint' + AND type = 'P' + ) +BEGIN + PRINT 'Proc exist with name dbo.dropTableConstraint' + DROP PROCEDURE dbo.dropTableConstraint + PRINT 'Proc dropped dbo.dropTableConstraint' +END +GO +*/ diff --git a/security-admin/scripts/db_setup.py b/security-admin/scripts/db_setup.py index 24502f4fb1..7dee806172 100644 --- a/security-admin/scripts/db_setup.py +++ b/security-admin/scripts/db_setup.py @@ -194,19 +194,22 @@ def apply_patches(self, db_name, db_user, db_password, PATCHES_PATH): pre_dict = {} post_dict = {} version = filename.split('-')[0] - prefix_for_preSql_patch=pre_sql_prefix + version - prefix_for_postSql_patch=post_sql_prefix +version - #getting Java patch which needs to be run before this DB patch. - pre_dict = self.get_pre_post_java_patches(prefix_for_preSql_patch) - if pre_dict: - log ("[I] ruunig pre java patch:[{}]".format(pre_dict),"info") - self.execute_java_patches(xa_db_host, db_user, db_password, db_name, pre_dict) - self.import_db_patches(db_name, db_user, db_password, currentPatch) - #getting Java patch which needs to be run immediately after this DB patch. - post_dict = self.get_pre_post_java_patches(prefix_for_postSql_patch) - if post_dict: - log ("[I] ruunig post java patch:[{}]".format(post_dict),"info") - self.execute_java_patches(xa_db_host, db_user, db_password, db_name, post_dict) + if version.endswith('SKIP'): + log ("[I] skipping patch {}".format(filename), "info") + else: + prefix_for_preSql_patch=pre_sql_prefix + version + prefix_for_postSql_patch=post_sql_prefix +version + #getting Java patch which needs to be run before this DB patch. + pre_dict = self.get_pre_post_java_patches(prefix_for_preSql_patch) + if pre_dict: + log ("[I] running pre java patch:[{}]".format(pre_dict),"info") + self.execute_java_patches(xa_db_host, db_user, db_password, db_name, pre_dict) + self.import_db_patches(db_name, db_user, db_password, currentPatch) + #getting Java patch which needs to be run immediately after this DB patch. + post_dict = self.get_pre_post_java_patches(prefix_for_postSql_patch) + if post_dict: + log ("[I] running post java patch:[{}]".format(post_dict),"info") + self.execute_java_patches(xa_db_host, db_user, db_password, db_name, post_dict) self.update_applied_patches_status(db_name, db_user, db_password, "DB_PATCHES") else: log("[I] No patches to apply!","info") diff --git a/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java b/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java index 6cc3509d86..d4a05c1f4e 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java @@ -53,7 +53,6 @@ import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemCondition; import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemDataMaskInfo; import org.apache.ranger.plugin.model.RangerRole; -import org.apache.ranger.service.RangerAuditFields; import org.apache.ranger.service.XGroupService; import org.apache.ranger.view.VXGroup; import org.apache.ranger.view.VXResponse; @@ -76,9 +75,6 @@ public enum PRINCIPAL_TYPE { USER, GROUP, ROLE } @Autowired RangerDaoManager daoMgr; - @Autowired - RangerAuditFields rangerAuditFields; - @Autowired XUserMgr xUserMgr; @@ -158,7 +154,7 @@ public void createNewPolMappingForRefTable(RangerPolicy policy, XXPolicy xPolicy throw new Exception(resource + ": is not a valid resource-type. policy='"+ policy.getName() + "' service='"+ policy.getService() + "'"); } - XXPolicyRefResource xPolRes = rangerAuditFields.populateAuditFields(new XXPolicyRefResource(), xPolicy); + XXPolicyRefResource xPolRes = new XXPolicyRefResource(); xPolRes.setPolicyId(policy.getId()); xPolRes.setResourceDefId(xResDef.getId()); @@ -233,7 +229,7 @@ public void createNewPolMappingForRefTable(RangerPolicy policy, XXPolicy xPolicy throw new Exception(accessType + ": is not a valid access-type. policy='" + policy.getName() + "' service='" + policy.getService() + "'"); } - XXPolicyRefAccessType xPolAccess = rangerAuditFields.populateAuditFields(new XXPolicyRefAccessType(), xPolicy); + XXPolicyRefAccessType xPolAccess = new XXPolicyRefAccessType(); xPolAccess.setPolicyId(policy.getId()); xPolAccess.setAccessDefId(xAccTypeDef.getId()); @@ -251,7 +247,7 @@ public void createNewPolMappingForRefTable(RangerPolicy policy, XXPolicy xPolicy throw new Exception(condition + ": is not a valid condition-type. policy='"+ xPolicy.getName() + "' service='"+ xPolicy.getService() + "'"); } - XXPolicyRefCondition xPolCond = rangerAuditFields.populateAuditFields(new XXPolicyRefCondition(), xPolicy); + XXPolicyRefCondition xPolCond = new XXPolicyRefCondition(); xPolCond.setPolicyId(policy.getId()); xPolCond.setConditionDefId(xPolCondDef.getId()); @@ -444,7 +440,7 @@ private void createPolicyAssociation(Long id, String name) { } switch (type) { case USER: { - XXPolicyRefUser xPolUser = rangerAuditFields.populateAuditFields(new XXPolicyRefUser(), xPolicy); + XXPolicyRefUser xPolUser = new XXPolicyRefUser(); xPolUser.setPolicyId(xPolicy.getId()); xPolUser.setUserId(id); @@ -453,7 +449,7 @@ private void createPolicyAssociation(Long id, String name) { } break; case GROUP: { - XXPolicyRefGroup xPolGroup = rangerAuditFields.populateAuditFields(new XXPolicyRefGroup(), xPolicy); + XXPolicyRefGroup xPolGroup = new XXPolicyRefGroup(); xPolGroup.setPolicyId(xPolicy.getId()); xPolGroup.setGroupId(id); @@ -462,7 +458,7 @@ private void createPolicyAssociation(Long id, String name) { } break; case ROLE: { - XXPolicyRefRole xPolRole = rangerAuditFields.populateAuditFields(new XXPolicyRefRole(), xPolicy); + XXPolicyRefRole xPolRole = new XXPolicyRefRole(); xPolRole.setPolicyId(xPolicy.getId()); xPolRole.setRoleId(id); diff --git a/security-admin/src/main/java/org/apache/ranger/biz/RoleRefUpdater.java b/security-admin/src/main/java/org/apache/ranger/biz/RoleRefUpdater.java index 421b2312da..664ca268b8 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/RoleRefUpdater.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/RoleRefUpdater.java @@ -327,7 +327,7 @@ private void createRoleAssociation(Long id, String name) { } switch (type) { case USER: { - XXRoleRefUser xRoleRefUser = rangerAuditFields.populateAuditFieldsForCreate(new XXRoleRefUser()); + XXRoleRefUser xRoleRefUser = new XXRoleRefUser(); xRoleRefUser.setRoleId(roleId); xRoleRefUser.setUserId(id); @@ -337,7 +337,7 @@ private void createRoleAssociation(Long id, String name) { } break; case GROUP: { - XXRoleRefGroup xRoleRefGroup = rangerAuditFields.populateAuditFieldsForCreate(new XXRoleRefGroup()); + XXRoleRefGroup xRoleRefGroup = new XXRoleRefGroup(); xRoleRefGroup.setRoleId(roleId); xRoleRefGroup.setGroupId(id); @@ -347,7 +347,7 @@ private void createRoleAssociation(Long id, String name) { } break; case ROLE: { - XXRoleRefRole xRoleRefRole = rangerAuditFields.populateAuditFieldsForCreate(new XXRoleRefRole()); + XXRoleRefRole xRoleRefRole = new XXRoleRefRole(); xRoleRefRole.setRoleId(roleId); xRoleRefRole.setSubRoleId(id); diff --git a/security-admin/src/main/java/org/apache/ranger/biz/SecurityZoneRefUpdater.java b/security-admin/src/main/java/org/apache/ranger/biz/SecurityZoneRefUpdater.java index 4cfe62701c..84c120497c 100644 --- a/security-admin/src/main/java/org/apache/ranger/biz/SecurityZoneRefUpdater.java +++ b/security-admin/src/main/java/org/apache/ranger/biz/SecurityZoneRefUpdater.java @@ -117,7 +117,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon RangerService rService = svcService.getPopulatedViewObject(xService); xServiceDef = daoMgr.getXXServiceDef().findByName(rService.getType()); - XXSecurityZoneRefService xZoneService = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefService()); + XXSecurityZoneRefService xZoneService = new XXSecurityZoneRefService(); xZoneService.setZoneId(zoneId); xZoneService.setServiceId(xService.getId()); @@ -134,7 +134,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon XXResourceDef xResourceDef = daoMgr.getXXResourceDef().findByNameAndServiceDefId(resourceName, xServiceDef.getId()); - XXSecurityZoneRefResource xZoneResource = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefResource()); + XXSecurityZoneRefResource xZoneResource = new XXSecurityZoneRefResource(); xZoneResource.setZoneId(zoneId); xZoneResource.setResourceDefId(xResourceDef.getId()); @@ -158,7 +158,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon MessageEnums.INVALID_INPUT_DATA); } - XXSecurityZoneRefTagService xZoneTagService = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefTagService()); + XXSecurityZoneRefTagService xZoneTagService = new XXSecurityZoneRefTagService(); xZoneTagService.setZoneId(zoneId); xZoneTagService.setTagServiceId(xService.getId()); @@ -182,7 +182,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon MessageEnums.INVALID_INPUT_DATA); } - XXSecurityZoneRefUser xZoneAdminUser = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefUser()); + XXSecurityZoneRefUser xZoneAdminUser = new XXSecurityZoneRefUser(); xZoneAdminUser.setZoneId(zoneId); xZoneAdminUser.setUserId(xUser.getId()); @@ -207,7 +207,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon MessageEnums.INVALID_INPUT_DATA); } - XXSecurityZoneRefGroup xZoneAdminGroup = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefGroup()); + XXSecurityZoneRefGroup xZoneAdminGroup = new XXSecurityZoneRefGroup(); xZoneAdminGroup.setZoneId(zoneId); xZoneAdminGroup.setGroupId(xGroup.getId()); @@ -232,7 +232,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon MessageEnums.INVALID_INPUT_DATA); } - XXSecurityZoneRefUser xZoneAuditUser = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefUser()); + XXSecurityZoneRefUser xZoneAuditUser = new XXSecurityZoneRefUser(); xZoneAuditUser.setZoneId(zoneId); xZoneAuditUser.setUserId(xUser.getId()); @@ -256,7 +256,7 @@ public void createNewZoneMappingForRefTable(RangerSecurityZone rangerSecurityZon MessageEnums.INVALID_INPUT_DATA); } - XXSecurityZoneRefGroup xZoneAuditGroup = rangerAuditFields.populateAuditFieldsForCreate(new XXSecurityZoneRefGroup()); + XXSecurityZoneRefGroup xZoneAuditGroup = new XXSecurityZoneRefGroup(); xZoneAuditGroup.setZoneId(zoneId); xZoneAuditGroup.setGroupId(xGroup.getId()); diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java index 6af8f99f4b..72efe5916e 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefAccessType.java @@ -26,7 +26,7 @@ @Cacheable @XmlRootElement @Table(name = "x_policy_ref_access_type") -public class XXPolicyRefAccessType extends XXDBBase implements +public class XXPolicyRefAccessType implements java.io.Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java index 4f4409d6af..02a4f3c8bf 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefCondition.java @@ -26,7 +26,7 @@ @Cacheable @XmlRootElement @Table(name = "x_policy_ref_condition") -public class XXPolicyRefCondition extends XXDBBase implements +public class XXPolicyRefCondition implements java.io.Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java index cb926740e9..85f2467f86 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefDataMaskType.java @@ -26,7 +26,7 @@ @Cacheable @XmlRootElement @Table(name = "x_policy_ref_datamask_type") -public class XXPolicyRefDataMaskType extends XXDBBase implements +public class XXPolicyRefDataMaskType implements java.io.Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java index 32a1b9f24c..7933cfbd57 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefGroup.java @@ -41,7 +41,7 @@ @Cacheable @XmlRootElement @Table(name="x_policy_ref_group") -public class XXPolicyRefGroup extends XXDBBase implements Serializable { +public class XXPolicyRefGroup implements Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java index 1150646210..46a8a77253 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefResource.java @@ -26,7 +26,7 @@ @Cacheable @XmlRootElement @Table(name = "x_policy_ref_resource") -public class XXPolicyRefResource extends XXDBBase implements +public class XXPolicyRefResource implements java.io.Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java index 7aee502e02..4487c611c4 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefRole.java @@ -41,7 +41,7 @@ @Cacheable @XmlRootElement @Table(name="x_policy_ref_role") -public class XXPolicyRefRole extends XXDBBase implements Serializable { +public class XXPolicyRefRole implements Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java index 8dfb928336..54ecd0510e 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXPolicyRefUser.java @@ -26,7 +26,7 @@ @Cacheable @XmlRootElement @Table(name = "x_policy_ref_user") -public class XXPolicyRefUser extends XXDBBase implements +public class XXPolicyRefUser implements java.io.Serializable { private static final long serialVersionUID = 1L; /** diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefGroup.java b/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefGroup.java index 22b9447916..3b3115d4a3 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefGroup.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefGroup.java @@ -40,7 +40,7 @@ @Cacheable @XmlRootElement @Table(name="x_role_ref_group") -public class XXRoleRefGroup extends XXDBBase implements Serializable { +public class XXRoleRefGroup implements Serializable { private static final long serialVersionUID = 1L; diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefRole.java b/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefRole.java index 30867e28d7..7e0f394d44 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefRole.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefRole.java @@ -39,7 +39,7 @@ @Cacheable @XmlRootElement @Table(name="x_role_ref_role") -public class XXRoleRefRole extends XXDBBase implements Serializable { +public class XXRoleRefRole implements Serializable { private static final long serialVersionUID = 1L; diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefUser.java b/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefUser.java index a5b17f716e..2fbed17550 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefUser.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXRoleRefUser.java @@ -40,7 +40,7 @@ @Cacheable @XmlRootElement @Table(name="x_role_ref_user") -public class XXRoleRefUser extends XXDBBase implements Serializable { +public class XXRoleRefUser implements Serializable { private static final long serialVersionUID = 1L; diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefGroup.java b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefGroup.java index 0ae6b2ffce..e532581d53 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefGroup.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefGroup.java @@ -34,7 +34,7 @@ @Cacheable @XmlRootElement @Table(name = "x_security_zone_ref_group") -public class XXSecurityZoneRefGroup extends XXDBBase implements java.io.Serializable{ +public class XXSecurityZoneRefGroup implements java.io.Serializable{ private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name = "x_sec_zone_ref_group_SEQ", sequenceName = "x_sec_zone_ref_group_SEQ", allocationSize = 1) @@ -86,12 +86,10 @@ public class XXSecurityZoneRefGroup extends XXDBBase implements java.io.Serializ * Value to set member attribute id */ - @Override public void setId(Long id) { this.id = id; } - @Override public Long getId() { return id; } diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefResource.java index 3d7197a161..d12a6542e3 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefResource.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefResource.java @@ -34,7 +34,7 @@ @Cacheable @XmlRootElement @Table(name = "x_security_zone_ref_resource") -public class XXSecurityZoneRefResource extends XXDBBase implements java.io.Serializable{ +public class XXSecurityZoneRefResource implements java.io.Serializable{ private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name = "x_sec_zone_ref_resource_SEQ", sequenceName = "x_sec_zone_ref_resource_SEQ", allocationSize = 1) @@ -77,12 +77,10 @@ public class XXSecurityZoneRefResource extends XXDBBase implements java.io.Seria * Value to set member attribute id */ - @Override public void setId(Long id) { this.id = id; } - @Override public Long getId() { return id; } diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefService.java b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefService.java index a2cacc6741..8d85cf6ce8 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefService.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefService.java @@ -34,7 +34,7 @@ @Cacheable @XmlRootElement @Table(name = "x_security_zone_ref_service") -public class XXSecurityZoneRefService extends XXDBBase implements java.io.Serializable{ +public class XXSecurityZoneRefService implements java.io.Serializable{ private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name = "x_sec_zone_ref_service_SEQ", sequenceName = "x_sec_zone_ref_service_SEQ", allocationSize = 1) @@ -77,12 +77,10 @@ public class XXSecurityZoneRefService extends XXDBBase implements java.io.Serial * Value to set member attribute id */ - @Override public void setId(Long id) { this.id = id; } - @Override public Long getId() { return id; } diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefTagService.java b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefTagService.java index c67a4648d0..69b3fa4452 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefTagService.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefTagService.java @@ -33,7 +33,7 @@ @Cacheable @XmlRootElement @Table(name = "x_security_zone_ref_tag_srvc") -public class XXSecurityZoneRefTagService extends XXDBBase implements java.io.Serializable{ +public class XXSecurityZoneRefTagService implements java.io.Serializable{ private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name = "x_sec_zone_ref_tag_srvc_SEQ", sequenceName = "x_sec_zone_ref_tag_srvc_SEQ", allocationSize = 1) @@ -50,12 +50,10 @@ public class XXSecurityZoneRefTagService extends XXDBBase implements java.io.Ser @Column(name = "tag_srvc_name") protected String tagServiceName; - @Override public void setId(Long id) { this.id=id; } - @Override public Long getId() { return id; } diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefUser.java b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefUser.java index 4af242fd38..222be9e968 100644 --- a/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefUser.java +++ b/security-admin/src/main/java/org/apache/ranger/entity/XXSecurityZoneRefUser.java @@ -34,7 +34,7 @@ @Cacheable @XmlRootElement @Table(name = "x_security_zone_ref_user") -public class XXSecurityZoneRefUser extends XXDBBase implements java.io.Serializable{ +public class XXSecurityZoneRefUser implements java.io.Serializable{ private static final long serialVersionUID = 1L; @Id @SequenceGenerator(name = "x_sec_zone_ref_user_SEQ", sequenceName = "x_sec_zone_ref_user_SEQ", allocationSize = 1) @@ -86,12 +86,10 @@ public class XXSecurityZoneRefUser extends XXDBBase implements java.io.Serializa * Value to set member attribute id */ - @Override public void setId(Long id) { this.id = id; } - @Override public Long getId() { return id; } diff --git a/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java b/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java index 85e457efa8..2691537bcd 100644 --- a/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java +++ b/security-admin/src/main/java/org/apache/ranger/service/XPortalUserService.java @@ -288,42 +288,12 @@ public void updateXXPortalUserReferences(long xXPortalUserId){ daoManager.getXXPolicyLabels().updateUserIDReference("upd_by_id", xXPortalUserId); daoManager.getXXPolicyLabelMap().updateUserIDReference("added_by_id", xXPortalUserId); daoManager.getXXPolicyLabelMap().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefCondition().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefCondition().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefGroup().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefGroup().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefDataMaskType().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefDataMaskType().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefResource().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefResource().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefUser().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefUser().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefAccessType().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefAccessType().updateUserIDReference("upd_by_id", xXPortalUserId); //2.0 //Note: skipping x_policy_change_log table as it does not have 'added_by_id' and 'upd_by_id' fields - daoManager.getXXSecurityZoneRefGroup().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefGroup().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefUser().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefUser().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefResource().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefResource().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefTagService().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefTagService().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefService().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXSecurityZoneRefService().updateUserIDReference("upd_by_id", xXPortalUserId); daoManager.getXXGlobalState().updateUserIDReference("added_by_id", xXPortalUserId); daoManager.getXXGlobalState().updateUserIDReference("upd_by_id", xXPortalUserId); daoManager.getXXSecurityZoneDao().updateUserIDReference("added_by_id", xXPortalUserId); daoManager.getXXSecurityZoneDao().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXRoleRefRole().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXRoleRefRole().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXRoleRefGroup().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXRoleRefGroup().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXRoleRefUser().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXRoleRefUser().updateUserIDReference("upd_by_id", xXPortalUserId); - daoManager.getXXPolicyRefRole().updateUserIDReference("added_by_id", xXPortalUserId); - daoManager.getXXPolicyRefRole().updateUserIDReference("upd_by_id", xXPortalUserId); daoManager.getXXRole().updateUserIDReference("added_by_id", xXPortalUserId); daoManager.getXXRole().updateUserIDReference("upd_by_id", xXPortalUserId); } diff --git a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java index 691ab52b3b..9c60713027 100644 --- a/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java +++ b/security-admin/src/test/java/org/apache/ranger/biz/TestServiceDBStore.java @@ -842,32 +842,21 @@ public void test13deleteServiceDef() throws Exception { policyRefAccessType.setId(Id); policyRefAccessType.setAccessTypeName("myAccessType"); policyRefAccessType.setPolicyId(Id); - policyRefAccessType.setCreateTime(new Date()); - policyRefAccessType.setUpdateTime(new Date()); - policyRefAccessType.setAddedByUserId(Id); - policyRefAccessType.setUpdatedByUserId(Id); policyRefAccessTypeList.add(policyRefAccessType); List policyRefConditionsList = new ArrayList(); XXPolicyRefCondition policyRefCondition = new XXPolicyRefCondition(); policyRefCondition.setId(Id); - policyRefCondition.setAddedByUserId(Id); policyRefCondition.setConditionDefId(Id); policyRefCondition.setConditionName("myConditionName"); policyRefCondition.setPolicyId(Id); - policyRefCondition.setUpdatedByUserId(Id); - policyRefCondition.setCreateTime(new Date()); - policyRefCondition.setUpdateTime(new Date()); policyRefConditionsList.add(policyRefCondition); List policyRefResourcesList = new ArrayList(); XXPolicyRefResource policyRefResource = new XXPolicyRefResource(); - policyRefResource.setAddedByUserId(Id); - policyRefResource.setCreateTime(new Date()); policyRefResource.setId(Id); policyRefResource.setPolicyId(Id); policyRefResource.setResourceDefId(Id); - policyRefResource.setUpdateTime(new Date()); policyRefResource.setResourceName("myresourceName"); policyRefResourcesList.add(policyRefResource);