You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ranger.apache.org by pr...@apache.org on 2019/01/24 03:48:35 UTC
[ranger] branch ranger-1.1 updated: RANGER-2320: Make db schema
patches script idempotent for all DB Flavors
This is an automated email from the ASF dual-hosted git repository.
pradeep pushed a commit to branch ranger-1.1
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/ranger-1.1 by this push:
new dfdde7f RANGER-2320: Make db schema patches script idempotent for all DB Flavors
dfdde7f is described below
commit dfdde7ff65f6fc7084f7a06696f22aca151817c2
Author: Pradeep <pr...@apache.org>
AuthorDate: Wed Jan 23 14:18:29 2019 +0530
RANGER-2320: Make db schema patches script idempotent for all DB Flavors
---
.../db/mysql/patches/009-updated_schema.sql | 50 +++++++++-------------
.../db/mysql/patches/013-permissionmodel.sql | 4 +-
.../db/mysql/patches/020-datamask-policy.sql | 4 +-
.../db/mysql/patches/030-policy-labels-schema.sql | 3 +-
.../patches/035-update-schema-for-x-policy.sql | 17 +++-----
.../optimized/current/ranger_core_db_oracle.sql | 2 +-
.../db/postgres/patches/020-datamask-policy.sql | 4 +-
.../patches/035-update-schema-for-x-policy.sql | 27 +++++++-----
.../db/sqlserver/patches/020-datamask-policy.sql | 9 ++--
.../patches/035-update-schema-for-x-policy.sql | 50 +++++++++++-----------
10 files changed, 81 insertions(+), 89 deletions(-)
diff --git a/security-admin/db/mysql/patches/009-updated_schema.sql b/security-admin/db/mysql/patches/009-updated_schema.sql
index 14ec1d8..085c50d 100644
--- a/security-admin/db/mysql/patches/009-updated_schema.sql
+++ b/security-admin/db/mysql/patches/009-updated_schema.sql
@@ -16,7 +16,27 @@
-- Temporary table structure for view `vx_trx_log`
--
+DROP TABLE IF EXISTS `x_data_hist`;
+DROP TABLE IF EXISTS `x_policy_item_group_perm`;
+DROP TABLE IF EXISTS `x_policy_item_user_perm`;
+DROP TABLE IF EXISTS `x_policy_item_condition`;
+DROP TABLE IF EXISTS `x_policy_item_access`;
+DROP TABLE IF EXISTS `x_policy_item`;
+DROP TABLE IF EXISTS `x_policy_resource_map`;
+DROP TABLE IF EXISTS `x_policy_resource`;
+DROP TABLE IF EXISTS `x_service_config_map`;
+DROP TABLE IF EXISTS `x_enum_element_def`;
+DROP TABLE IF EXISTS `x_enum_def`;
+DROP TABLE IF EXISTS `x_context_enricher_def`;
+DROP TABLE IF EXISTS `x_policy_condition_def`;
+DROP TABLE IF EXISTS `x_access_type_def_grants`;
+DROP TABLE IF EXISTS `x_access_type_def`;
+DROP TABLE IF EXISTS `x_resource_def`;
+DROP TABLE IF EXISTS `x_service_config_def`;
+DROP TABLE IF EXISTS `x_policy`;
+DROP TABLE IF EXISTS `x_service`;
DROP TABLE IF EXISTS `x_service_def`;
+
CREATE TABLE `x_service_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -41,8 +61,6 @@ CONSTRAINT `x_service_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES
CONSTRAINT `x_service_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_service`;
CREATE TABLE `x_service` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -69,7 +87,6 @@ CONSTRAINT `x_service_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_port
CONSTRAINT `x_service_FK_type` FOREIGN KEY (`type`) REFERENCES `x_service_def` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_policy`;
CREATE TABLE `x_policy` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -97,8 +114,6 @@ CONSTRAINT `x_policy_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_porta
CONSTRAINT `x_policy_FK_service` FOREIGN KEY (`service`) REFERENCES `x_service` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_service_config_def`;
CREATE TABLE `x_service_config_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -128,8 +143,6 @@ CONSTRAINT `x_service_config_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REF
CONSTRAINT `x_service_config_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_resource_def`;
CREATE TABLE `x_resource_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -166,7 +179,6 @@ CONSTRAINT `x_resource_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCE
CONSTRAINT `x_resource_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_access_type_def`;
CREATE TABLE `x_access_type_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -186,7 +198,6 @@ CONSTRAINT `x_access_type_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERE
CONSTRAINT `x_access_type_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_access_type_def_grants`;
CREATE TABLE `x_access_type_def_grants` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -202,7 +213,6 @@ CONSTRAINT `x_atd_grants_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES
CONSTRAINT `x_atd_grants_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_policy_condition_def`;
CREATE TABLE `x_policy_condition_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -230,7 +240,6 @@ CONSTRAINT `x_policy_condition_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) R
CONSTRAINT `x_policy_condition_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_context_enricher_def`;
CREATE TABLE `x_context_enricher_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -250,7 +259,6 @@ CONSTRAINT `x_context_enricher_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) R
CONSTRAINT `x_context_enricher_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_enum_def`;
CREATE TABLE `x_enum_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -268,8 +276,6 @@ CONSTRAINT `x_enum_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES `x
CONSTRAINT `x_enum_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_enum_element_def`;
CREATE TABLE `x_enum_element_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -289,8 +295,6 @@ CONSTRAINT `x_enum_element_def_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFER
CONSTRAINT `x_enum_element_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_service_config_map`;
CREATE TABLE `x_service_config_map` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -307,8 +311,6 @@ CONSTRAINT `x_service_config_map_FK_added_by_id` FOREIGN KEY (`added_by_id`) REF
CONSTRAINT `x_service_config_map_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_policy_resource`;
CREATE TABLE `x_policy_resource` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -327,8 +329,6 @@ CONSTRAINT `x_policy_resource_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERE
CONSTRAINT `x_policy_resource_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_policy_resource_map`;
CREATE TABLE `x_policy_resource_map` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -345,9 +345,6 @@ CONSTRAINT `x_policy_resource_map_FK_added_by_id` FOREIGN KEY (`added_by_id`) RE
CONSTRAINT `x_policy_resource_map_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-
-DROP TABLE IF EXISTS `x_policy_item`;
CREATE TABLE `x_policy_item` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -364,8 +361,6 @@ CONSTRAINT `x_policy_item_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCES
CONSTRAINT `x_policy_item_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_policy_item_access`;
CREATE TABLE `x_policy_item_access` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -384,7 +379,6 @@ CONSTRAINT `x_policy_item_access_FK_added_by_id` FOREIGN KEY (`added_by_id`) REF
CONSTRAINT `x_policy_item_access_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_policy_item_condition`;
CREATE TABLE `x_policy_item_condition` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -403,7 +397,6 @@ CONSTRAINT `x_policy_item_condition_FK_added_by_id` FOREIGN KEY (`added_by_id`)
CONSTRAINT `x_policy_item_condition_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_policy_item_user_perm`;
CREATE TABLE `x_policy_item_user_perm` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -421,8 +414,6 @@ CONSTRAINT `x_policy_item_user_perm_FK_added_by_id` FOREIGN KEY (`added_by_id`)
CONSTRAINT `x_policy_item_user_perm_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_policy_item_group_perm`;
CREATE TABLE `x_policy_item_group_perm` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
@@ -440,7 +431,6 @@ CONSTRAINT `x_policy_item_group_perm_FK_added_by_id` FOREIGN KEY (`added_by_id`)
CONSTRAINT `x_policy_item_group_perm_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_data_hist`;
CREATE TABLE `x_data_hist` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`create_time` datetime DEFAULT NULL,
diff --git a/security-admin/db/mysql/patches/013-permissionmodel.sql b/security-admin/db/mysql/patches/013-permissionmodel.sql
index 1c6bcfd..5bc4868 100644
--- a/security-admin/db/mysql/patches/013-permissionmodel.sql
+++ b/security-admin/db/mysql/patches/013-permissionmodel.sql
@@ -13,6 +13,8 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
+DROP TABLE IF EXISTS `x_group_module_perm`;
+DROP TABLE IF EXISTS `x_user_module_perm`;
DROP TABLE IF EXISTS `x_modules_master`;
CREATE TABLE `x_modules_master` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
@@ -37,7 +39,6 @@ DELIMITER ;
INSERT INTO `x_modules_master` (`create_time`,`update_time`,`added_by_id`,`upd_by_id`,`module`,`url`) VALUES (now(),now(),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),'Resource Based Policies',''),(now(),now(),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),'Users/Groups',''),(now(),now(),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),'Reports',''),(now(),now(),getXportalUIdByLoginId('admin'),getXportalUIdByLoginId('admin'),'Audit',''), [...]
-DROP TABLE IF EXISTS `x_user_module_perm`;
CREATE TABLE `x_user_module_perm` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) NULL DEFAULT NULL,
@@ -54,7 +55,6 @@ CONSTRAINT `x_user_module_perm_FK_module_id` FOREIGN KEY (`module_id`) REFERENCE
CONSTRAINT `x_user_module_perm_FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `x_portal_user` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_group_module_perm`;
CREATE TABLE `x_group_module_perm` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`group_id` bigint(20) NULL DEFAULT NULL,
diff --git a/security-admin/db/mysql/patches/020-datamask-policy.sql b/security-admin/db/mysql/patches/020-datamask-policy.sql
index 87c0a18..2ec2909 100644
--- a/security-admin/db/mysql/patches/020-datamask-policy.sql
+++ b/security-admin/db/mysql/patches/020-datamask-policy.sql
@@ -51,6 +51,8 @@ delimiter ;
call add_datamask_options_to_x_resource_def_table();
drop procedure if exists add_datamask_options_to_x_resource_def_table;
+DROP TABLE IF EXISTS `x_policy_item_rowfilter`;
+DROP TABLE IF EXISTS `x_policy_item_datamask`;
DROP TABLE IF EXISTS `x_datamask_type_def`;
CREATE TABLE `x_datamask_type_def` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
@@ -76,7 +78,6 @@ CONSTRAINT `x_datamask_type_def_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENC
)ROW_FORMAT=DYNAMIC;
CREATE INDEX x_datamask_type_def_IDX_def_id ON x_datamask_type_def(def_id);
-DROP TABLE IF EXISTS `x_policy_item_datamask`;
CREATE TABLE `x_policy_item_datamask` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(64) NULL DEFAULT NULL,
@@ -96,7 +97,6 @@ CONSTRAINT `x_policy_item_datamask_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFER
)ROW_FORMAT=DYNAMIC;
CREATE INDEX x_policy_item_datamask_IDX_policy_item_id ON x_policy_item_datamask(policy_item_id);
-DROP TABLE IF EXISTS `x_policy_item_rowfilter`;
CREATE TABLE `x_policy_item_rowfilter` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(64) NULL DEFAULT NULL,
diff --git a/security-admin/db/mysql/patches/030-policy-labels-schema.sql b/security-admin/db/mysql/patches/030-policy-labels-schema.sql
index 33af2a8..b4afd51 100644
--- a/security-admin/db/mysql/patches/030-policy-labels-schema.sql
+++ b/security-admin/db/mysql/patches/030-policy-labels-schema.sql
@@ -13,6 +13,7 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
+DROP TABLE IF EXISTS `x_policy_label_map`;
DROP TABLE IF EXISTS `x_policy_label`;
CREATE TABLE `x_policy_label` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
@@ -33,7 +34,7 @@ CONSTRAINT `x_policy_label_FK_added_by_id` FOREIGN KEY (`added_by_id`) REFERENCE
CONSTRAINT `x_policy_label_FK_upd_by_id` FOREIGN KEY (`upd_by_id`) REFERENCES `x_portal_user` (`id`)
)ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_policy_label_map`;
+
CREATE TABLE `x_policy_label_map` (
`id` bigint(20) NOT NULL AUTO_INCREMENT ,
`guid` varchar(1024) DEFAULT NULL,
diff --git a/security-admin/db/mysql/patches/035-update-schema-for-x-policy.sql b/security-admin/db/mysql/patches/035-update-schema-for-x-policy.sql
index 84db526..5181063 100644
--- a/security-admin/db/mysql/patches/035-update-schema-for-x-policy.sql
+++ b/security-admin/db/mysql/patches/035-update-schema-for-x-policy.sql
@@ -109,9 +109,12 @@ call removeConstraints('x_policy_item_rowfilter');
call removeConstraints('x_policy_resource');
call removeConstraints('x_policy_resource_map');
-
DROP PROCEDURE removeConstraints;
-
+DROP TABLE IF EXISTS `x_policy_ref_group`;
+DROP TABLE IF EXISTS `x_policy_ref_user`;
+DROP TABLE IF EXISTS `x_policy_ref_datamask_type`;
+DROP TABLE IF EXISTS `x_policy_ref_condition`;
+DROP TABLE IF EXISTS `x_policy_ref_access_type`;
DROP TABLE IF EXISTS `x_policy_ref_resource`;
CREATE TABLE IF NOT EXISTS `x_policy_ref_resource` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
@@ -129,11 +132,8 @@ CREATE TABLE IF NOT EXISTS `x_policy_ref_resource` (
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;
-
-DROP TABLE IF EXISTS `x_policy_ref_access_type`;
CREATE TABLE IF NOT EXISTS `x_policy_ref_access_type` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`guid` varchar(1024) DEFAULT NULL,
@@ -152,8 +152,6 @@ CREATE TABLE IF NOT EXISTS `x_policy_ref_access_type` (
CONSTRAINT `x_policy_ref_access_FK_access_def_id` FOREIGN KEY (`access_def_id`) REFERENCES `x_access_type_def` (`id`)
) ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_policy_ref_condition`;
CREATE TABLE IF NOT EXISTS `x_policy_ref_condition` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`guid` varchar(1024) DEFAULT NULL,
@@ -170,10 +168,8 @@ CREATE TABLE IF NOT EXISTS `x_policy_ref_condition` (
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;
-DROP TABLE IF EXISTS `x_policy_ref_datamask_type`;
CREATE TABLE IF NOT EXISTS `x_policy_ref_datamask_type` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`guid` varchar(1024) DEFAULT NULL,
@@ -192,7 +188,6 @@ CREATE TABLE IF NOT EXISTS `x_policy_ref_datamask_type` (
CONSTRAINT `x_policy_ref_datamask_FK_datamask_def_id` FOREIGN KEY (`datamask_def_id`) REFERENCES `x_datamask_type_def` (`id`)
) ROW_FORMAT=DYNAMIC;
-DROP TABLE IF EXISTS `x_policy_ref_user`;
CREATE TABLE IF NOT EXISTS `x_policy_ref_user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`guid` varchar(1024) DEFAULT NULL,
@@ -211,8 +206,6 @@ CREATE TABLE IF NOT EXISTS `x_policy_ref_user` (
CONSTRAINT `x_policy_ref_user_FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `x_user` (`id`)
) ROW_FORMAT=DYNAMIC;
-
-DROP TABLE IF EXISTS `x_policy_ref_group`;
CREATE TABLE IF NOT EXISTS `x_policy_ref_group` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`guid` varchar(1024) DEFAULT NULL,
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 7340d18..ba462cc 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
@@ -84,7 +84,6 @@ call spdropsequence('X_PLUGIN_INFO_SEQ');
call spdropsequence('X_POLICY_LABEL_MAP_SEQ');
call spdropsequence('X_POLICY_LABEL_SEQ');
call spdropsequence('X_UGSYNC_AUDIT_INFO_SEQ');
-call spdropsequence('X_DB_VERSION_H_SEQ');
CREATE SEQUENCE SEQ_GEN_IDENTITY START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE X_ACCESS_AUDIT_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE X_ASSET_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
@@ -145,6 +144,7 @@ CREATE SEQUENCE X_PLUGIN_INFO_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE X_POLICY_LABEL_MAP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE X_POLICY_LABEL_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
CREATE SEQUENCE X_UGSYNC_AUDIT_INFO_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
+call spdropsequence('X_DB_VERSION_H_SEQ');
CREATE SEQUENCE X_DB_VERSION_H_SEQ START WITH 1 INCREMENT BY 1 NOCACHE NOCYCLE;
commit;
diff --git a/security-admin/db/postgres/patches/020-datamask-policy.sql b/security-admin/db/postgres/patches/020-datamask-policy.sql
index 795721c..79a509b 100644
--- a/security-admin/db/postgres/patches/020-datamask-policy.sql
+++ b/security-admin/db/postgres/patches/020-datamask-policy.sql
@@ -13,10 +13,10 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
-DROP TABLE IF EXISTS x_datamask_type_def;
DROP TABLE IF EXISTS x_policy_item_datamask;
-DROP SEQUENCE IF EXISTS x_datamask_type_def_seq;
DROP SEQUENCE IF EXISTS x_policy_item_datamask_def_seq;
+DROP TABLE IF EXISTS x_datamask_type_def;
+DROP SEQUENCE IF EXISTS x_datamask_type_def_seq;
CREATE SEQUENCE x_datamask_type_def_seq;
CREATE TABLE x_datamask_type_def (
diff --git a/security-admin/db/postgres/patches/035-update-schema-for-x-policy.sql b/security-admin/db/postgres/patches/035-update-schema-for-x-policy.sql
index 61c7986..3575d7d 100644
--- a/security-admin/db/postgres/patches/035-update-schema-for-x-policy.sql
+++ b/security-admin/db/postgres/patches/035-update-schema-for-x-policy.sql
@@ -12,8 +12,20 @@
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
+
+DROP TABLE IF EXISTS x_policy_ref_group CASCADE;
+DROP SEQUENCE IF EXISTS x_policy_ref_group_seq;
+DROP TABLE IF EXISTS x_policy_ref_user CASCADE;
+DROP SEQUENCE IF EXISTS x_policy_ref_user_seq;
+DROP TABLE IF EXISTS x_policy_ref_datamask_type CASCADE;
+DROP SEQUENCE IF EXISTS x_policy_ref_datamask_type_seq;
+DROP TABLE IF EXISTS x_policy_ref_condition CASCADE;
+DROP SEQUENCE IF EXISTS x_policy_ref_condition_seq;
+DROP TABLE IF EXISTS x_policy_ref_access_type CASCADE;
+DROP SEQUENCE IF EXISTS x_policy_ref_access_type_seq;
DROP TABLE IF EXISTS x_policy_ref_resource CASCADE;
DROP SEQUENCE IF EXISTS x_policy_ref_resource_seq;
+
CREATE SEQUENCE x_policy_ref_resource_seq;
CREATE TABLE x_policy_ref_resource(
id BIGINT DEFAULT nextval('x_policy_ref_resource_seq'::regclass),
@@ -33,8 +45,7 @@ CONSTRAINT x_p_ref_res_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_port
CONSTRAINT x_p_ref_res_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id)
);
commit;
-DROP TABLE IF EXISTS x_policy_ref_access_type CASCADE;
-DROP SEQUENCE IF EXISTS x_policy_ref_access_type_seq;
+
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),
@@ -54,8 +65,7 @@ CONSTRAINT x_p_ref_acc_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_port
CONSTRAINT x_p_ref_acc_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id)
);
commit;
-DROP TABLE IF EXISTS x_policy_ref_condition CASCADE;
-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),
@@ -75,8 +85,7 @@ CONSTRAINT x_p_ref_cond_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_por
CONSTRAINT x_p_ref_cond_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id)
);
commit;
-DROP TABLE IF EXISTS x_policy_ref_datamask_type CASCADE;
-DROP SEQUENCE IF EXISTS x_policy_ref_datamask_type_seq;
+
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),
@@ -96,8 +105,7 @@ CONSTRAINT x_p_ref_dmk_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_port
CONSTRAINT x_p_ref_dmk_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id)
);
commit;
-DROP TABLE IF EXISTS x_policy_ref_user CASCADE;
-DROP SEQUENCE IF EXISTS x_policy_ref_user_seq;
+
CREATE SEQUENCE x_policy_ref_user_seq;
CREATE TABLE x_policy_ref_user(
id BIGINT DEFAULT nextval('x_policy_ref_user_seq'::regclass),
@@ -117,8 +125,7 @@ CONSTRAINT x_p_ref_usr_FK_added_by_id FOREIGN KEY(added_by_id) REFERENCES x_port
CONSTRAINT x_p_ref_usr_FK_upd_by_id FOREIGN KEY(upd_by_id) REFERENCES x_portal_user(id)
);
commit;
-DROP TABLE IF EXISTS x_policy_ref_group CASCADE;
-DROP SEQUENCE IF EXISTS x_policy_ref_group_seq;
+
CREATE SEQUENCE x_policy_ref_group_seq;
CREATE TABLE x_policy_ref_group(
id BIGINT DEFAULT nextval('x_policy_ref_group_seq'::regclass),
diff --git a/security-admin/db/sqlserver/patches/020-datamask-policy.sql b/security-admin/db/sqlserver/patches/020-datamask-policy.sql
index c50d2b8..bd658e5 100644
--- a/security-admin/db/sqlserver/patches/020-datamask-policy.sql
+++ b/security-admin/db/sqlserver/patches/020-datamask-policy.sql
@@ -64,9 +64,9 @@ BEGIN
ALTER TABLE [dbo].[x_policy_item_rowfilter] DROP CONSTRAINT x_policy_item_rowfilter_FK_upd_by_id
END
GO
-IF (OBJECT_ID('x_datamask_type_def') IS NOT NULL)
+IF (OBJECT_ID('x_policy_item_rowfilter') IS NOT NULL)
BEGIN
- DROP TABLE [dbo].[x_datamask_type_def]
+ DROP TABLE [dbo].[x_policy_item_rowfilter]
END
GO
IF (OBJECT_ID('x_policy_item_datamask') IS NOT NULL)
@@ -74,10 +74,11 @@ BEGIN
DROP TABLE [dbo].[x_policy_item_datamask]
END
GO
-IF (OBJECT_ID('x_policy_item_rowfilter') IS NOT NULL)
+IF (OBJECT_ID('x_datamask_type_def') IS NOT NULL)
BEGIN
- DROP TABLE [dbo].[x_policy_item_rowfilter]
+ DROP TABLE [dbo].[x_datamask_type_def]
END
+GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
diff --git a/security-admin/db/sqlserver/patches/035-update-schema-for-x-policy.sql b/security-admin/db/sqlserver/patches/035-update-schema-for-x-policy.sql
index bd646d6..5b3ea05 100644
--- a/security-admin/db/sqlserver/patches/035-update-schema-for-x-policy.sql
+++ b/security-admin/db/sqlserver/patches/035-update-schema-for-x-policy.sql
@@ -28,11 +28,6 @@ BEGIN
ALTER TABLE [dbo].[x_policy_ref_resource] DROP CONSTRAINT x_policy_ref_resource_UK
END
GO
-IF (OBJECT_ID('x_policy_ref_resource') IS NOT NULL)
-BEGIN
- DROP TABLE [dbo].[x_policy_ref_resource]
-END
-GO
IF (OBJECT_ID('x_policy_ref_access_type_FK_policy_id') IS NOT NULL)
BEGIN
ALTER TABLE [dbo].[x_policy_ref_access_type] DROP CONSTRAINT x_policy_ref_access_type_FK_policy_id
@@ -48,11 +43,6 @@ BEGIN
ALTER TABLE [dbo].[x_policy_ref_access_type] DROP CONSTRAINT x_policy_ref_access_type_UK
END
GO
-IF (OBJECT_ID('x_policy_ref_access_type') IS NOT NULL)
-BEGIN
- DROP TABLE [dbo].[x_policy_ref_access_type]
-END
-GO
IF (OBJECT_ID('x_policy_ref_condition_FK_policy_id') IS NOT NULL)
BEGIN
ALTER TABLE [dbo].[x_policy_ref_condition] DROP CONSTRAINT x_policy_ref_condition_FK_policy_id
@@ -68,11 +58,6 @@ BEGIN
ALTER TABLE [dbo].[x_policy_ref_condition] DROP CONSTRAINT x_policy_ref_condition_UK
END
GO
-IF (OBJECT_ID('x_policy_ref_condition') IS NOT NULL)
-BEGIN
- DROP TABLE [dbo].[x_policy_ref_condition]
-END
-GO
IF (OBJECT_ID('x_policy_ref_datamask_type_FK_policy_id') IS NOT NULL)
BEGIN
ALTER TABLE [dbo].[x_policy_ref_datamask_type] DROP CONSTRAINT x_policy_ref_datamask_type_FK_policy_id
@@ -88,11 +73,6 @@ BEGIN
ALTER TABLE [dbo].[x_policy_ref_datamask_type] DROP CONSTRAINT x_policy_ref_datamask_type_UK
END
GO
-IF (OBJECT_ID('x_policy_ref_datamask_type') IS NOT NULL)
-BEGIN
- DROP TABLE [dbo].[x_policy_ref_datamask_type]
-END
-GO
IF (OBJECT_ID('x_policy_ref_user_FK_policy_id') IS NOT NULL)
BEGIN
ALTER TABLE [dbo].[x_policy_ref_user] DROP CONSTRAINT x_policy_ref_user_FK_policy_id
@@ -108,11 +88,6 @@ BEGIN
ALTER TABLE [dbo].[x_policy_ref_user] DROP CONSTRAINT x_policy_ref_user_UK
END
GO
-IF (OBJECT_ID('x_policy_ref_user') IS NOT NULL)
-BEGIN
- DROP TABLE [dbo].[x_policy_ref_user]
-END
-GO
IF (OBJECT_ID('x_policy_ref_group_FK_policy_id') IS NOT NULL)
BEGIN
ALTER TABLE [dbo].[x_policy_ref_group] DROP CONSTRAINT x_policy_ref_group_FK_policy_id
@@ -133,6 +108,31 @@ BEGIN
DROP TABLE [dbo].[x_policy_ref_group]
END
GO
+IF (OBJECT_ID('x_policy_ref_user') IS NOT NULL)
+BEGIN
+ DROP TABLE [dbo].[x_policy_ref_user]
+END
+GO
+IF (OBJECT_ID('x_policy_ref_datamask_type') IS NOT NULL)
+BEGIN
+ DROP TABLE [dbo].[x_policy_ref_datamask_type]
+END
+GO
+IF (OBJECT_ID('x_policy_ref_condition') IS NOT NULL)
+BEGIN
+ DROP TABLE [dbo].[x_policy_ref_condition]
+END
+GO
+IF (OBJECT_ID('x_policy_ref_access_type') IS NOT NULL)
+BEGIN
+ DROP TABLE [dbo].[x_policy_ref_access_type]
+END
+GO
+IF (OBJECT_ID('x_policy_ref_resource') IS NOT NULL)
+BEGIN
+ DROP TABLE [dbo].[x_policy_ref_resource]
+END
+GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON