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 2020/02/26 10:56:16 UTC

[ranger] 02/02: Revert "RANGER-2713: Remove audit fields from XXPolicyRef objects XXPolicyRef objects have fields such as create time, update time, added by user ID, updated by user ID, but there fields are entirely useless since they are all copied from the XXPolicy object. In addition, while improving performance for creation of policies with large numbers of users, we discovered that a lot of time was being spent in JPA converting these Date objects especially. After removing these fields we saw a sign [...]

This is an automated email from the ASF dual-hosted git repository.

pradeep pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit f37f5407eee8d2627a4306a25938b151f8e2ba31
Author: Pradeep <pr...@apache.org>
AuthorDate: Wed Feb 26 15:58:38 2020 +0530

    Revert "RANGER-2713: Remove audit fields from XXPolicyRef objects XXPolicyRef objects have fields such as create time, update time, added by user ID, updated by user ID, but there fields are entirely useless since they are all copied from the XXPolicy object. In addition, while improving performance for creation of policies with large numbers of users, we discovered that a lot of time was being spent in JPA converting these Date objects especially. After removing these fields we saw a [...]
    
    This reverts commit b4c32849245b40d100a583b0b214a69f9b678a44.
---
 ...6-drop-audit-columns-from-policy-ref-tables.sql |  90 ----------
 ...6-drop-audit-columns-from-policy-ref-tables.sql |  61 -------
 ...6-drop-audit-columns-from-policy-ref-tables.sql |  49 -----
 ...6-drop-audit-columns-from-policy-ref-tables.sql | 129 --------------
 ...6-drop-audit-columns-from-policy-ref-tables.sql | 197 ---------------------
 .../org/apache/ranger/biz/PolicyRefUpdater.java    |  17 +-
 .../ranger/entity/XXPolicyRefAccessType.java       |   2 +-
 .../apache/ranger/entity/XXPolicyRefCondition.java |   2 +-
 .../ranger/entity/XXPolicyRefDataMaskType.java     |   2 +-
 .../org/apache/ranger/entity/XXPolicyRefGroup.java |   2 +-
 .../apache/ranger/entity/XXPolicyRefResource.java  |   2 +-
 .../org/apache/ranger/entity/XXPolicyRefRole.java  |   2 +-
 .../org/apache/ranger/entity/XXPolicyRefUser.java  |   2 +-
 .../org/apache/ranger/biz/TestServiceDBStore.java  |  11 ++
 14 files changed, 29 insertions(+), 539 deletions(-)

diff --git a/security-admin/db/mysql/patches/046-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/mysql/patches/046-drop-audit-columns-from-policy-ref-tables.sql
deleted file mode 100644
index e1db3c6..0000000
--- a/security-admin/db/mysql/patches/046-drop-audit-columns-from-policy-ref-tables.sql
+++ /dev/null
@@ -1,90 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License.  You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
-drop procedure if exists 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', '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', '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', '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', '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', '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', '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');
-
-drop procedure if exists drop_table_column;
-drop procedure if exists drop_table_foreign_key;
diff --git a/security-admin/db/oracle/patches/046-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/oracle/patches/046-drop-audit-columns-from-policy-ref-tables.sql
deleted file mode 100644
index 405ed6b..0000000
--- a/security-admin/db/oracle/patches/046-drop-audit-columns-from-policy-ref-tables.sql
+++ /dev/null
@@ -1,61 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License.  You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
-CREATE OR REPLACE PROCEDURE 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', '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', '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', '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', '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', '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', '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');
diff --git a/security-admin/db/postgres/patches/046-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/postgres/patches/046-drop-audit-columns-from-policy-ref-tables.sql
deleted file mode 100644
index 73ead4e..0000000
--- a/security-admin/db/postgres/patches/046-drop-audit-columns-from-policy-ref-tables.sql
+++ /dev/null
@@ -1,49 +0,0 @@
--- 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.
-
-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 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 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 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 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 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;
diff --git a/security-admin/db/sqlanywhere/patches/046-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/sqlanywhere/patches/046-drop-audit-columns-from-policy-ref-tables.sql
deleted file mode 100644
index 10508f6..0000000
--- a/security-admin/db/sqlanywhere/patches/046-drop-audit-columns-from-policy-ref-tables.sql
+++ /dev/null
@@ -1,129 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License.  You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
-CREATE OR REPLACE PROCEDURE dbo.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', 'create_time')
-GO
-call dbo.dropTableColumn('x_policy_ref_resource', 'update_time')
-GO
-call dbo.dropTableConstraint('x_policy_ref_resource', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_resource', 'x_policy_ref_resource_FK_added_by')
-GO
-call dbo.dropTableConstraint('x_policy_ref_resource', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_resource', 'x_policy_ref_resource_FK_upd_by')
-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', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_role', 'x_pol_ref_role_FK_upd_by_id')
-GO
-call dbo.dropTableConstraint('x_policy_ref_role', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_role', 'x_pol_ref_role_FK_upd_by_id')
-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', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_group', 'x_policy_ref_group_FK_added_by')
-GO
-call dbo.dropTableConstraint('x_policy_ref_group', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_group', 'x_policy_ref_group_FK_upd_by')
-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', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_user', 'x_policy_ref_user_FK_added_by')
-GO
-call dbo.dropTableConstraint('x_policy_ref_user', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_user', 'x_policy_ref_user_FK_upd_by')
-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', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_access_type', 'x_policy_ref_access_type_FK_added_by')
-GO
-call dbo.dropTableConstraint('x_policy_ref_access_type', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_access_type', 'x_policy_ref_access_type_FK_upd_by')
-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', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_condition', 'x_policy_ref_condition_FK_added_by')
-GO
-call dbo.dropTableConstraint('x_policy_ref_condition', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_condition', 'x_policy_ref_condition_FK_upd_by')
-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', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_added_by')
-GO
-call dbo.dropTableConstraint('x_policy_ref_datamask_type', 'added_by_id')
-GO
-call dbo.dropTableColumn('x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_upd_by')
-GO
diff --git a/security-admin/db/sqlserver/patches/046-drop-audit-columns-from-policy-ref-tables.sql b/security-admin/db/sqlserver/patches/046-drop-audit-columns-from-policy-ref-tables.sql
deleted file mode 100644
index 1af3ec4..0000000
--- a/security-admin/db/sqlserver/patches/046-drop-audit-columns-from-policy-ref-tables.sql
+++ /dev/null
@@ -1,197 +0,0 @@
--- Licensed to the Apache Software Foundation (ASF) under one or more
--- contributor license agreements.  See the NOTICE file distributed with
--- this work for additional information regarding copyright ownership.
--- The ASF licenses this file to You under the Apache License, Version 2.0
--- (the "License"); you may not use this file except in compliance with
--- the License.  You may obtain a copy of the License at
---
---     http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
-
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-SET ANSI_PADDING ON
-GO
-IF EXISTS (
-        SELECT type_desc, type
-        FROM sys.procedures WITH(NOLOCK)
-        WHERE NAME = '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', 'create_time'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'update_time'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_resource', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'x_policy_ref_resource_FK_added_by'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_resource', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_resource', 'x_policy_ref_resource_FK_upd_by'
-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', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_role', 'x_policy_ref_role_FK_added_by_id'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_role', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_role', 'x_policy_ref_role_FK_upd_by_id'
-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', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_group', 'x_policy_ref_group_FK_added_by'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_group', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_group', 'x_policy_ref_group_FK_upd_by'
-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', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_user', 'x_policy_ref_user_FK_added_by'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_user', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_user', 'x_policy_ref_user_FK_upd_by'
-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', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'x_policy_ref_access_type_FK_added_by'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_access_type', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_access_type', 'x_policy_ref_access_type_FK_upd_by'
-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', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'x_policy_ref_condition_FK_added_by'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_condition', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_condition', 'x_policy_ref_condition_FK_upd_by'
-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', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_added_by'
-GO
-EXEC dbo.dropTableConstraint 'x_policy_ref_datamask_type', 'added_by_id'
-GO
-EXEC dbo.dropTableColumn 'x_policy_ref_datamask_type', 'x_policy_ref_datamask_type_FK_upd_by'
-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/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java b/security-admin/src/main/java/org/apache/ranger/biz/PolicyRefUpdater.java
index 41d235a..baacfa4 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
@@ -52,6 +52,7 @@ import org.apache.ranger.plugin.model.RangerPolicy.RangerPolicyItemAccess;
 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.XUserService;
 import org.apache.ranger.view.VXGroup;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -67,8 +68,12 @@ public class PolicyRefUpdater {
 	RangerDaoManager daoMgr;
 
 	@Autowired
+	RangerAuditFields<?> rangerAuditFields;
+
+	@Autowired
 	XUserMgr xUserMgr;
 
+
 	@Autowired
 	XUserService xUserService;
 
@@ -139,7 +144,7 @@ public class PolicyRefUpdater {
 				throw new Exception(resource + ": is not a valid resource-type. policy='"+  policy.getName() + "' service='"+ policy.getService() + "'");
 			}
 
-			XXPolicyRefResource xPolRes = new XXPolicyRefResource();
+			XXPolicyRefResource xPolRes = rangerAuditFields.populateAuditFields(new XXPolicyRefResource(), xPolicy);
 
 			xPolRes.setPolicyId(policy.getId());
 			xPolRes.setResourceDefId(xResDef.getId());
@@ -164,7 +169,7 @@ public class PolicyRefUpdater {
 				RangerBizUtil.setBulkMode(false);
 				roleId = createRoleForPolicy(role);
 			}
-			XXPolicyRefRole xPolRole = new XXPolicyRefRole();
+			XXPolicyRefRole xPolRole = rangerAuditFields.populateAuditFields(new XXPolicyRefRole(), xPolicy);
 
 			xPolRole.setPolicyId(policy.getId());
 			xPolRole.setRoleId(roleId);
@@ -191,7 +196,7 @@ public class PolicyRefUpdater {
 				groupId = createGroupForPolicy(group);
 			}
 
-			XXPolicyRefGroup xPolGroup = new XXPolicyRefGroup();
+			XXPolicyRefGroup xPolGroup = rangerAuditFields.populateAuditFields(new XXPolicyRefGroup(), xPolicy);
 
 			xPolGroup.setPolicyId(policy.getId());
 			xPolGroup.setGroupId(groupId);
@@ -219,7 +224,7 @@ public class PolicyRefUpdater {
 				userId = createUserForPolicy(user);
 			}
 
-			XXPolicyRefUser xPolUser = new XXPolicyRefUser();
+			XXPolicyRefUser xPolUser = rangerAuditFields.populateAuditFields(new XXPolicyRefUser(), xPolicy);
 
 			xPolUser.setPolicyId(policy.getId());
 			xPolUser.setUserId(userId);
@@ -238,7 +243,7 @@ public class PolicyRefUpdater {
 				throw new Exception(accessType + ": is not a valid access-type. policy='" + policy.getName() + "' service='" + policy.getService() + "'");
 			}
 
-			XXPolicyRefAccessType xPolAccess = new XXPolicyRefAccessType();
+			XXPolicyRefAccessType xPolAccess = rangerAuditFields.populateAuditFields(new XXPolicyRefAccessType(), xPolicy);
 
 			xPolAccess.setPolicyId(policy.getId());
 			xPolAccess.setAccessDefId(xAccTypeDef.getId());
@@ -256,7 +261,7 @@ public class PolicyRefUpdater {
 				throw new Exception(condition + ": is not a valid condition-type. policy='"+  xPolicy.getName() + "' service='"+ xPolicy.getService() + "'");
 			}
 
-			XXPolicyRefCondition xPolCond = new XXPolicyRefCondition();
+			XXPolicyRefCondition xPolCond = rangerAuditFields.populateAuditFields(new XXPolicyRefCondition(), xPolicy);
 
 			xPolCond.setPolicyId(policy.getId());
 			xPolCond.setConditionDefId(xPolCondDef.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 72efe59..6af8f99 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 @@ import java.util.Objects;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_policy_ref_access_type")
-public class XXPolicyRefAccessType implements
+public class XXPolicyRefAccessType extends XXDBBase 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 02a4f3c..4f4409d 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 @@ import java.util.Objects;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_policy_ref_condition")
-public class XXPolicyRefCondition implements
+public class XXPolicyRefCondition extends XXDBBase 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 85f2467..cb92674 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 @@ import java.util.Objects;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_policy_ref_datamask_type")
-public class XXPolicyRefDataMaskType implements
+public class XXPolicyRefDataMaskType extends XXDBBase 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 7933cfb..32a1b9f 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 @@ import javax.xml.bind.annotation.XmlRootElement;
 @Cacheable
 @XmlRootElement
 @Table(name="x_policy_ref_group")
-public class XXPolicyRefGroup implements Serializable {
+public class XXPolicyRefGroup extends XXDBBase 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 46a8a77..1150646 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 @@ import java.util.Objects;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_policy_ref_resource")
-public class XXPolicyRefResource implements
+public class XXPolicyRefResource extends XXDBBase 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 4487c61..7aee502 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 @@ import javax.xml.bind.annotation.XmlRootElement;
 @Cacheable
 @XmlRootElement
 @Table(name="x_policy_ref_role")
-public class XXPolicyRefRole implements Serializable {
+public class XXPolicyRefRole extends XXDBBase 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 54ecd05..8dfb928 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 @@ import java.util.Objects;
 @Cacheable
 @XmlRootElement
 @Table(name = "x_policy_ref_user")
-public class XXPolicyRefUser implements
+public class XXPolicyRefUser extends XXDBBase implements
 		java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 	/**
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 7abd888..69c8a4c 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
@@ -832,21 +832,32 @@ public class TestServiceDBStore {
 		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<XXPolicyRefCondition> policyRefConditionsList = new ArrayList<XXPolicyRefCondition>();
 		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<XXPolicyRefResource> policyRefResourcesList = new ArrayList<XXPolicyRefResource>();
 		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);