ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mad...@apache.org
Subject [19/50] [abbrv] incubator-ranger git commit: RANGER-645: updates to support all DB flavors for TagDBStore
Date Wed, 28 Oct 2015 15:59:55 GMT
http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/db/sqlserver/patches/016-updated-schema-for-tag-based-policy.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/sqlserver/patches/016-updated-schema-for-tag-based-policy.sql b/security-admin/db/sqlserver/patches/016-updated-schema-for-tag-based-policy.sql
new file mode 100644
index 0000000..af9f083
--- /dev/null
+++ b/security-admin/db/sqlserver/patches/016-updated-schema-for-tag-based-policy.sql
@@ -0,0 +1,575 @@
+-- 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.
+
+GO
+IF (OBJECT_ID('x_tag_def_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_def] DROP CONSTRAINT x_tag_def_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_def_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_def] DROP CONSTRAINT x_tag_def_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag] DROP CONSTRAINT x_tag_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag] DROP CONSTRAINT x_tag_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_FK_type') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag] DROP CONSTRAINT x_tag_FK_type
+END
+GO
+IF (OBJECT_ID('x_service_res_FK_service_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource] DROP CONSTRAINT x_service_res_FK_service_id
+END
+GO
+IF (OBJECT_ID('x_service_res_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource] DROP CONSTRAINT x_service_res_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_service_res_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource] DROP CONSTRAINT x_service_res_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_FK_res_def_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element] DROP CONSTRAINT x_srvc_res_el_FK_res_def_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_FK_res_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element] DROP CONSTRAINT x_srvc_res_el_FK_res_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element] DROP CONSTRAINT x_srvc_res_el_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element] DROP CONSTRAINT x_srvc_res_el_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_def_FK_tag_def_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_attr_def] DROP CONSTRAINT x_tag_attr_def_FK_tag_def_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_def_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_attr_def] DROP CONSTRAINT x_tag_attr_def_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_def_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_attr_def] DROP CONSTRAINT x_tag_attr_def_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_FK_tag_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_attr] DROP CONSTRAINT x_tag_attr_FK_tag_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_attr] DROP CONSTRAINT x_tag_attr_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_attr] DROP CONSTRAINT x_tag_attr_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_res_map_FK_tag_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_resource_map] DROP CONSTRAINT x_tag_res_map_FK_tag_id
+END
+GO
+IF (OBJECT_ID('x_tag_attr_FK_tag_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_resource_map] DROP CONSTRAINT x_tag_res_map_FK_res_id
+END
+GO
+IF (OBJECT_ID('x_tag_res_map_FK_added_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_resource_map] DROP CONSTRAINT x_tag_res_map_FK_added_by_id
+END
+GO
+IF (OBJECT_ID('x_tag_res_map_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_tag_resource_map] DROP CONSTRAINT x_tag_res_map_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_val_FK_res_el_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element_val] DROP CONSTRAINT x_srvc_res_el_val_FK_res_el_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_val_FK_add_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element_val] DROP CONSTRAINT x_srvc_res_el_val_FK_add_by_id
+END
+GO
+IF (OBJECT_ID('x_srvc_res_el_val_FK_upd_by_id') IS NOT NULL)
+BEGIN
+    ALTER TABLE [dbo].[x_service_resource_element_val] DROP CONSTRAINT x_srvc_res_el_val_FK_upd_by_id
+END
+GO
+IF (OBJECT_ID('x_service_resource_element_val') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_service_resource_element_val]
+END
+GO
+IF (OBJECT_ID('x_tag_resource_map') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_tag_resource_map]
+END
+GO
+IF (OBJECT_ID('x_tag_attr') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_tag_attr]
+END
+GO
+IF (OBJECT_ID('x_tag_attr_def') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_tag_attr_def]
+END
+GO
+IF (OBJECT_ID('x_service_resource_element') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_service_resource_element]
+END
+GO
+IF (OBJECT_ID('x_service_resource') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_service_resource]
+END
+GO
+IF (OBJECT_ID('x_tag') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_tag]
+END
+GO
+IF (OBJECT_ID('x_tag_def') IS NOT NULL)
+BEGIN
+    DROP TABLE [dbo].[x_tag_def]
+END
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_tag_def](
+	[id] [bigint] IDENTITY(1,1) NOT NULL,
+	[guid] [varchar](64) 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,
+	[version] [bigint] DEFAULT NULL NULL,
+	[name] [varchar](255) NOT NULL,
+	[source] [varchar](128) DEFAULT NULL NULL,
+	[is_enabled] [tinyint] DEFAULT 0 NOT NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
+CONSTRAINT [x_tag_def$x_tag_def_UK_guid] UNIQUE NONCLUSTERED 
+(
+	[guid] ASC
+)WITH (PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
+CONSTRAINT [x_tag_def$x_tag_def_UK_name] UNIQUE NONCLUSTERED 
+(
+	[name] ASC
+)WITH (PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_tag](
+	[id] [bigint] IDENTITY(1,1) NOT NULL,
+	[guid] [varchar](64) 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,
+	[type] [bigint] NOT NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
+CONSTRAINT [x_tag$x_tag_UK_guid] UNIQUE NONCLUSTERED 
+(
+	[guid] ASC
+)WITH (PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_service_resource](
+	[id] [bigint] IDENTITY(1,1) NOT NULL,
+	[guid] [varchar](64) 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,
+	[version] [bigint] DEFAULT NULL NULL,
+	[service_id] [bigint] NOT NULL,
+	[resource_signature] [varchar](128) DEFAULT NULL NULL,
+	[is_enabled] [tinyint] DEFAULT 1 NOT NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
+CONSTRAINT [x_service_resource$x_service_res_UK_guid] UNIQUE NONCLUSTERED 
+(
+	[guid] ASC
+)WITH (PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_service_resource_element](
+	[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,
+	[res_id] [bigint] NOT NULL,
+	[res_def_id] [bigint] NOT NULL,
+	[is_excludes] [tinyint] DEFAULT 0 NOT NULL,
+	[is_recursive] [tinyint] DEFAULT 0 NOT NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_tag_attr_def](
+	[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,
+	[tag_def_id] [bigint] NOT NULL,
+	[name] [varchar](255) NOT NULL,
+	[type] [varchar](50) NOT NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_tag_attr](
+	[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,
+	[tag_id] [bigint] NOT NULL,
+	[name] [varchar](255) NOT NULL,
+	[value] [varchar](512) DEFAULT NULL NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_tag_resource_map](
+	[id] [bigint] IDENTITY(1,1) NOT NULL,
+	[guid] [varchar](64) 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,
+	[tag_id] [bigint] NOT NULL,
+	[res_id] [bigint] NOT NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY],
+CONSTRAINT [x_tag_resource_map$x_tag_resource_map_UK_guid] UNIQUE NONCLUSTERED 
+(
+	[guid] ASC
+)WITH (PAD_INDEX = OFF,STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON,ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
+) ON [PRIMARY]
+GO
+SET ANSI_NULLS ON
+GO
+SET QUOTED_IDENTIFIER ON
+GO
+SET ANSI_PADDING ON
+GO
+CREATE TABLE [dbo].[x_service_resource_element_val](
+	[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,
+	[res_element_id] [bigint] NOT NULL,
+	[value] [varchar](1024) NOT NULL,
+	[sort_order] [tinyint] DEFAULT 0 NULL,
+	PRIMARY KEY CLUSTERED 
+(
+	[id] ASC
+)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_tag_def] WITH CHECK ADD CONSTRAINT [x_tag_def_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_def] WITH CHECK ADD CONSTRAINT [x_tag_def_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag] WITH CHECK ADD CONSTRAINT [x_tag_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag] WITH CHECK ADD CONSTRAINT [x_tag_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag] WITH CHECK ADD CONSTRAINT [x_tag_FK_type] FOREIGN KEY([type]) REFERENCES [dbo].[x_tag_def] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource] WITH CHECK ADD CONSTRAINT [x_service_res_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource] WITH CHECK ADD CONSTRAINT [x_service_res_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource] WITH CHECK ADD CONSTRAINT [x_service_res_FK_service_id] FOREIGN KEY([service_id]) REFERENCES [dbo].[x_service] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_FK_res_def_id] FOREIGN KEY([res_def_id]) REFERENCES [dbo].[x_resource_def] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_FK_res_id] FOREIGN KEY([res_id]) REFERENCES [dbo].[x_service_resource] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_attr_def] WITH CHECK ADD CONSTRAINT [x_tag_attr_def_FK_tag_def_id] FOREIGN KEY([tag_def_id]) REFERENCES [dbo].[x_tag_def] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_attr_def] WITH CHECK ADD CONSTRAINT [x_tag_attr_def_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_attr_def] WITH CHECK ADD CONSTRAINT [x_tag_attr_def_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_attr] WITH CHECK ADD CONSTRAINT [x_tag_attr_FK_tag_id] FOREIGN KEY([tag_id]) REFERENCES [dbo].[x_tag] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_attr] WITH CHECK ADD CONSTRAINT [x_tag_attr_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_attr] WITH CHECK ADD CONSTRAINT [x_tag_attr_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_resource_map] WITH CHECK ADD CONSTRAINT [x_tag_res_map_FK_tag_id] FOREIGN KEY([tag_id]) REFERENCES [dbo].[x_tag] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_resource_map] WITH CHECK ADD CONSTRAINT [x_tag_res_map_FK_res_id] FOREIGN KEY([res_id]) REFERENCES [dbo].[x_service_resource] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_resource_map] WITH CHECK ADD CONSTRAINT [x_tag_res_map_FK_added_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_tag_resource_map] WITH CHECK ADD CONSTRAINT [x_tag_res_map_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element_val] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_val_FK_res_el_id] FOREIGN KEY([res_element_id]) REFERENCES [dbo].[x_service_resource_element] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element_val] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_val_FK_add_by_id] FOREIGN KEY([added_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+ALTER TABLE [dbo].[x_service_resource_element_val] WITH CHECK ADD CONSTRAINT [x_srvc_res_el_val_FK_upd_by_id] FOREIGN KEY([upd_by_id]) REFERENCES [dbo].[x_portal_user] ([id])
+GO
+INSERT INTO x_modules_master(create_time,update_time,added_by_id,upd_by_id,module,url) VALUES(CURRENT_TIMESTAMP,CURRENT_TIMESTAMP,1,1,'Tag Based Policies','');
+GO
+CREATE NONCLUSTERED INDEX [x_tag_def_IDX_added_by_id] ON [x_tag_def]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_def_IDX_upd_by_id] ON [x_tag_def]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_IDX_type] ON [x_tag]
+(
+   [type] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_IDX_added_by_id] ON [x_tag]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_IDX_upd_by_id] ON [x_tag]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_service_res_IDX_added_by_id] ON [x_service_resource]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_service_res_IDX_upd_by_id] ON [x_service_resource]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_srvc_res_el_IDX_added_by_id] ON [x_service_resource_element]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_srvc_res_el_IDX_upd_by_id] ON [x_service_resource_element]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_attr_def_IDX_tag_def_id] ON [x_tag_attr_def]
+(
+   [tag_def_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_attr_def_IDX_added_by_id] ON [x_tag_attr_def]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_attr_def_IDX_upd_by_id] ON [x_tag_attr_def]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_attr_IDX_tag_id] ON [x_tag_attr]
+(
+   [tag_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_attr_IDX_added_by_id] ON [x_tag_attr]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_attr_IDX_upd_by_id] ON [x_tag_attr]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_res_map_IDX_tag_id] ON [x_tag_resource_map]
+(
+   [tag_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_res_map_IDX_res_id] ON [x_tag_resource_map]
+(
+   [res_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_res_map_IDX_added_by_id] ON [x_tag_resource_map]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_tag_res_map_IDX_upd_by_id] ON [x_tag_resource_map]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_srvc_res_el_val_IDX_resel_id] ON [x_service_resource_element_val]
+(
+   [res_element_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_srvc_res_el_val_IDX_addby_id] ON [x_service_resource_element_val]
+(
+   [added_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+CREATE NONCLUSTERED INDEX [x_srvc_res_el_val_IDX_updby_id] ON [x_service_resource_element_val]
+(
+   [upd_by_id] ASC
+)
+WITH (SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, IGNORE_DUP_KEY = OFF, ONLINE = OFF) ON [PRIMARY]
+GO
+
+IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_service_def' and column_name = 'def_options')
+BEGIN
+	ALTER TABLE [dbo].[x_service_def] ADD [def_options] [varchar](1024) DEFAULT NULL NULL;
+END
+GO
+
+IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_policy_item' and column_name in('item_type','is_enabled','comments'))
+BEGIN
+	ALTER TABLE [dbo].[x_policy_item] ADD [item_type] [int] DEFAULT 0 NOT NULL,[is_enabled] [tinyint] DEFAULT 1 NOT NULL,[comments] [varchar](255) DEFAULT NULL NULL;
+END
+GO
+
+IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'x_service' and column_name in('tag_service','tag_version','tag_update_time'))
+BEGIN
+	ALTER TABLE [dbo].[x_service] ADD [tag_service] [bigint] DEFAULT NULL NULL,[tag_version] [bigint] DEFAULT 0 NOT NULL,[tag_update_time] [datetime2] DEFAULT NULL NULL;
+END
+GO
+exit

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/db/sqlserver/patches/audit/017-add-new-column-to-store-tags.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/sqlserver/patches/audit/017-add-new-column-to-store-tags.sql b/security-admin/db/sqlserver/patches/audit/017-add-new-column-to-store-tags.sql
new file mode 100644
index 0000000..9446202
--- /dev/null
+++ b/security-admin/db/sqlserver/patches/audit/017-add-new-column-to-store-tags.sql
@@ -0,0 +1,21 @@
+-- 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.
+
+IF NOT EXISTS(select * from INFORMATION_SCHEMA.columns where table_name = 'xa_access_audit' and column_name = 'tags')
+BEGIN
+	ALTER TABLE [dbo].[xa_access_audit] ADD [tags] [varchar](4000) DEFAULT NULL NULL;
+END
+GO
+exit

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/db/sqlserver/xa_audit_db_sqlserver.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/sqlserver/xa_audit_db_sqlserver.sql b/security-admin/db/sqlserver/xa_audit_db_sqlserver.sql
index 783b968..effe509 100644
--- a/security-admin/db/sqlserver/xa_audit_db_sqlserver.sql
+++ b/security-admin/db/sqlserver/xa_audit_db_sqlserver.sql
@@ -43,7 +43,6 @@ CREATE TABLE [dbo].[xa_access_audit](
 	[request_data] [varchar](4000) DEFAULT NULL NULL,
 	[resource_path] [varchar](4000) DEFAULT NULL NULL,
 	[resource_type] [varchar](255) DEFAULT NULL NULL,
-	[tags] [varchar](4000) DEFAULT NULL NULL,
 	[seq_num] [bigint] DEFAULT 0 NULL,
 	[event_count] [bigint] DEFAULT 1 NULL,
 	[event_dur_ms] [bigint] DEFAULT 1 NULL,

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/db/sqlserver/xa_core_db_sqlserver.sql
----------------------------------------------------------------------
diff --git a/security-admin/db/sqlserver/xa_core_db_sqlserver.sql b/security-admin/db/sqlserver/xa_core_db_sqlserver.sql
index 6e304d4..a5b6559 100644
--- a/security-admin/db/sqlserver/xa_core_db_sqlserver.sql
+++ b/security-admin/db/sqlserver/xa_core_db_sqlserver.sql
@@ -414,7 +414,6 @@ CREATE TABLE [dbo].[xa_access_audit](
 	[request_data] [varchar](4000) DEFAULT NULL NULL,
 	[resource_path] [varchar](4000) DEFAULT NULL NULL,
 	[resource_type] [varchar](255) DEFAULT NULL NULL,
-	[tags] [varchar](4000) DEFAULT NULL NULL,
 PRIMARY KEY CLUSTERED
 (
 	[id] ASC
@@ -1527,11 +1526,6 @@ BEGIN
     ALTER TABLE [dbo].[x_service] DROP CONSTRAINT x_service_FK_type
 END
 GO
-IF (OBJECT_ID('x_service_FK_tag_service') IS NOT NULL)
-BEGIN
-    ALTER TABLE [dbo].[x_service] DROP CONSTRAINT x_service_FK_tag_service
-END
-GO
 IF (OBJECT_ID('x_policy_FK_added_by_id') IS NOT NULL)
 BEGIN
     ALTER TABLE [dbo].[x_policy] DROP CONSTRAINT x_policy_FK_added_by_id
@@ -1760,7 +1754,6 @@ CREATE TABLE [dbo].[x_service_def](
 	[impl_class_name] [varchar](1024) DEFAULT NULL NULL,
 	[label] [varchar](1024) DEFAULT NULL NULL,
 	[description] [varchar](1024) DEFAULT NULL NULL,
-	[options] [varchar](1024) DEFAULT NULL NULL,
 	[rb_key_label] [varchar](1024) DEFAULT NULL NULL,
 	[rb_key_description] [varchar](1024) DEFAULT NULL NULL,
 	[is_enabled] [tinyint] DEFAULT 1 NULL,
@@ -1790,7 +1783,6 @@ CREATE TABLE [dbo].[x_service] (
 	[policy_update_time] [datetime2] DEFAULT NULL NULL,
 	[description] [varchar](1024) DEFAULT NULL NULL,
 	[is_enabled] [tinyint] DEFAULT 0 NOT NULL,                        
-	[tag_service] [bigint] DEFAULT NULL NULL,
 PRIMARY KEY CLUSTERED 
 (
 	[id] ASC
@@ -2278,11 +2270,6 @@ REFERENCES [dbo].[x_service_def] ([id])
 GO
 ALTER TABLE [dbo].[x_service] CHECK CONSTRAINT [x_service_FK_type]
 GO
-ALTER TABLE [dbo].[x_service]  WITH CHECK ADD  CONSTRAINT [x_service_FK_tag_service] FOREIGN KEY([tag_service])
-REFERENCES [dbo].[x_service] ([id])
-GO
-ALTER TABLE [dbo].[x_service] CHECK CONSTRAINT [x_service_FK_tag_service]
-GO
 ALTER TABLE [dbo].[x_policy]  WITH CHECK ADD  CONSTRAINT [x_policy_FK_added_by_id] FOREIGN KEY([added_by_id])
 REFERENCES [dbo].[x_portal_user] ([id])
 GO

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/scripts/db_setup.py
----------------------------------------------------------------------
diff --git a/security-admin/scripts/db_setup.py b/security-admin/scripts/db_setup.py
index 1edc628..1465bcb 100644
--- a/security-admin/scripts/db_setup.py
+++ b/security-admin/scripts/db_setup.py
@@ -775,10 +775,10 @@ class PostgresConf(BaseDB):
 				if ret == 0:
 					log("[I] "+name + " patch applied","info")
 					if os_name == "LINUX":
-						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', now(), '%s@%s', now(), '%s@%s') ;\"" %(version,db_user,xa_db_host,db_user,xa_db_host)
+						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', current_timestamp, '%s', current_timestamp, '%s') ;\"" %(version,db_user,db_user)
 						ret = subprocess.call(shlex.split(query))
 					elif os_name == "WINDOWS":
-						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', now(), '%s@%s', now(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', current_timestamp, '%s', current_timestamp, '%s') ;\" -c ;" %(version,db_user,db_user)
 						ret = subprocess.call(query)
 					if ret == 0:
 						log("[I] Patch version updated", "info")
@@ -816,10 +816,10 @@ class PostgresConf(BaseDB):
 					if ret == 0:
 						log("[I] "+name + " patch applied","info")
 						if os_name == "LINUX":
-							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', now(), '%s@%s', now(), '%s@%s') ;\"" %(version,db_user,xa_db_host,db_user,xa_db_host)
+							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', current_timestamp, '%s', current_timestamp, '%s') ;\"" %(version,db_user,db_user)
 							ret = subprocess.call(shlex.split(query))
 						elif os_name == "WINDOWS":
-							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', now(), '%s@%s', now(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', current_timestamp, '%s', current_timestamp, '%s') ;\" -c ;" %(version,db_user,db_user)
 							ret = subprocess.call(query)
 						if ret == 0:
 							log("[I] Patch version updated", "info")
@@ -912,10 +912,10 @@ class PostgresConf(BaseDB):
 						if ret == 0:
 							get_cmd = self.get_jisql_cmd(db_user, db_password, db_name)
 							if os_name == "LINUX":
-								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', now(), '%s@%s', now(), '%s@%s') ;\"" %(version,db_user,xa_db_host,db_user,xa_db_host)
+								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', current_timestamp, '%s', current_timestamp, '%s') ;\"" %(version,db_user,db_user)
 								ret = subprocess.call(shlex.split(query))
 							elif os_name == "WINDOWS":
-								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', now(), '%s@%s', now(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', current_timestamp, '%s', current_timestamp, '%s') ;\" -c ;" %(version,db_user,db_user)
 								ret = subprocess.call(query)
 							if ret == 0:
 								log("[I] java patch "+ className +" applied", "info")
@@ -1011,7 +1011,7 @@ class SqlServerConf(BaseDB):
 			log("[I] Executing patch on " + db_name + " from file: " + name,"info")
 			get_cmd = self.get_jisql_cmd(db_user, db_password, db_name)
 			if os_name == "LINUX":
-				query = get_cmd + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
+				query = get_cmd + " -c \; -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
 			elif os_name == "WINDOWS":
 				query = get_cmd + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\" -c ;" %(version)
 			output = check_output(query)
@@ -1027,10 +1027,10 @@ class SqlServerConf(BaseDB):
 				if ret == 0:
 					log("[I] "+name + " patch applied","info")
 					if os_name == "LINUX":
-						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c \;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', CURRENT_TIMESTAMP, '%s', CURRENT_TIMESTAMP, '%s') ;\" -c \;" %(version,db_user,db_user)
 						ret = subprocess.call(shlex.split(query))
 					elif os_name == "WINDOWS":
-						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', CURRENT_TIMESTAMP, '%s', CURRENT_TIMESTAMP, '%s') ;\" -c ;" %(version,db_user,db_user)
 						ret = subprocess.call(query)
 					if ret == 0:
 						log("[I] Patch version updated", "info")
@@ -1051,7 +1051,7 @@ class SqlServerConf(BaseDB):
 				log("[I] Executing patch on " + audit_db_name + " from file: " + name,"info")
 				get_cmd1 = xa_sqlObj.get_jisql_cmd(db_user, db_password, db_name)
 				if os_name == "LINUX":
-					query = get_cmd1 + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
+					query = get_cmd1 + " -c \; -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
 				elif os_name == "WINDOWS":
 					query = get_cmd1 + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\" -c ;" %(version)
 				output = check_output(query)
@@ -1068,10 +1068,10 @@ class SqlServerConf(BaseDB):
 					if ret == 0:
 						log("[I] "+name + " patch applied","info")
 						if os_name == "LINUX":
-							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c \;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+							query = get_cmd1 + " -c \; -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', CURRENT_TIMESTAMP, '%s', CURRENT_TIMESTAMP, '%s') ;\"" %(version,db_user,db_user)
 							ret = subprocess.call(shlex.split(query))
 						elif os_name == "WINDOWS":
-							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', CURRENT_TIMESTAMP, '%s', CURRENT_TIMESTAMP, '%s') ;\" -c ;" %(version,db_user,db_user)
 							ret = subprocess.call(query)
 						if ret == 0:
 							log("[I] Patch version updated", "info")
@@ -1148,10 +1148,10 @@ class SqlServerConf(BaseDB):
 						if ret == 0:
 							get_cmd = self.get_jisql_cmd(db_user, db_password, db_name)
 							if os_name == "LINUX":
-								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c \;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', CURRENT_TIMESTAMP, '%s', CURRENT_TIMESTAMP, '%s') ;\" -c \;" %(version,db_user,db_user)
 								ret = subprocess.call(shlex.split(query))
 							elif os_name == "WINDOWS":
-								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', CURRENT_TIMESTAMP, '%s', CURRENT_TIMESTAMP, '%s') ;\" -c ;" %(version,db_user,db_user)
 								ret = subprocess.call(query)
 							if ret == 0:
 								log("[I] java patch "+ className  +" applied", "info")
@@ -1246,7 +1246,7 @@ class SqlAnywhereConf(BaseDB):
 			log("[I] Executing patch on " + db_name + " from file: " + name,"info")
 			get_cmd = self.get_jisql_cmd(db_user, db_password, db_name)
 			if os_name == "LINUX":
-				query = get_cmd + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
+				query = get_cmd + " -c \; -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
 			elif os_name == "WINDOWS":
 				query = get_cmd + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\" -c ;" %(version)
 			output = check_output(query)
@@ -1262,10 +1262,10 @@ class SqlAnywhereConf(BaseDB):
 				if ret == 0:
 					log("[I] "+name + " patch applied","info")
 					if os_name == "LINUX":
-						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c \;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s', GETDATE(), '%s') ;\" -c \;" %(version,db_user,db_user)
 						ret = subprocess.call(shlex.split(query))
 					elif os_name == "WINDOWS":
-						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+						query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s', GETDATE(), '%s') ;\" -c ;" %(version,db_user,db_user)
 						ret = subprocess.call(query)
 					if ret == 0:
 						log("[I] Patch version updated", "info")
@@ -1286,7 +1286,7 @@ class SqlAnywhereConf(BaseDB):
 				log("[I] Executing patch on " + audit_db_name + " from file: " + name,"info")
 				get_cmd1 = xa_sqlObj.get_jisql_cmd(db_user, db_password, db_name)
 				if os_name == "LINUX":
-					query = get_cmd1 + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
+					query = get_cmd1 + " -c \; -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\"" %(version)
 				elif os_name == "WINDOWS":
 					query = get_cmd1 + " -query \"select version from x_db_version_h where version = '%s' and active = 'Y';\" -c ;" %(version)
 				output = check_output(query)
@@ -1303,10 +1303,10 @@ class SqlAnywhereConf(BaseDB):
 					if ret == 0:
 						log("[I] "+name + " patch applied","info")
 						if os_name == "LINUX":
-							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c \;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s', GETDATE(), '%s') ;\" -c \;" %(version,db_user,db_user)
 							ret = subprocess.call(shlex.split(query))
 						elif os_name == "WINDOWS":
-							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+							query = get_cmd1 + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('%s', GETDATE(), '%s', GETDATE(), '%s') ;\" -c ;" %(version,db_user,db_user)
 							ret = subprocess.call(query)
 						if ret == 0:
 							log("[I] Patch version updated", "info")
@@ -1384,10 +1384,10 @@ class SqlAnywhereConf(BaseDB):
 						if ret == 0:
 							get_cmd = self.get_jisql_cmd(db_user, db_password, db_name)
 							if os_name == "LINUX":
-								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c \;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', GETDATE(), '%s', GETDATE(), '%s') ;\" -c \;" %(version,db_user,db_user)
 								ret = subprocess.call(shlex.split(query))
 							elif os_name == "WINDOWS":
-								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', GETDATE(), '%s@%s', GETDATE(), '%s@%s') ;\" -c ;" %(version,db_user,xa_db_host,db_user,xa_db_host)
+								query = get_cmd + " -query \"insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ('J%s', GETDATE(), '%s', GETDATE(), '%s') ;\" -c ;" %(version,db_user,db_user)
 								ret = subprocess.call(query)
 							if ret == 0:
 								log("[I] java patch "+ className  +" applied", "info")

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
index 868de4a..e704d98 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceDefBase.java
@@ -90,8 +90,8 @@ public abstract class XXServiceDefBase extends XXDBBase implements Serializable
 	 * </ul>
 	 *
 	 */
-	@Column(name = "options")
-	protected String options;
+	@Column(name = "def_options")
+	protected String defOptions;
 
 	/**
 	 * rbKeyLabel of the XXServiceDef
@@ -230,22 +230,22 @@ public abstract class XXServiceDefBase extends XXDBBase implements Serializable
 	}
 
 	/**
-	 * This method sets the value to the member attribute <b> options</b> .
+	 * This method sets the value to the member attribute <b> defOptions</b> .
 	 *
 	 * @param options
-	 *            Value to set member attribute <b> options</b>
+	 *            Value to set member attribute <b> defOptions</b>
 	 */
-	public void setOptions(String options) {
-		this.options = options;
+	public void setDefOptions(String options) {
+		this.defOptions = options;
 	}
 
 	/**
-	 * Returns the value for the member attribute <b>options</b>
+	 * Returns the value for the member attribute <b>defOptions</b>
 	 *
-	 * @return String - value of member attribute <b>options</b> .
+	 * @return String - value of member attribute <b>defOptions</b> .
 	 */
-	public String getOptions() {
-		return this.options;
+	public String getDefOptions() {
+		return this.defOptions;
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
index 2624154..6d92679 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResource.java
@@ -42,8 +42,8 @@ public class XXServiceResource extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXServiceResourceSEQ", sequenceName = "XXServiceResourceSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXServiceResourceSEQ")
+	@SequenceGenerator(name = "X_SERVICE_RESOURCE_SEQ", sequenceName = "X_SERVICE_RESOURCE_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_SERVICE_RESOURCE_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
index cd60736..48a079e 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElement.java
@@ -41,8 +41,8 @@ public class XXServiceResourceElement extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXServiceResourceElementSEQ", sequenceName = "XXServiceResourceElementSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXServiceResourceElementSEQ")
+	@SequenceGenerator(name = "X_SERVICE_RESOURCE_ELEMENT_SEQ", sequenceName = "X_SERVICE_RESOURCE_ELEMENT_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_SERVICE_RESOURCE_ELEMENT_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
index 77c83ec..7e8ba36 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXServiceResourceElementValue.java
@@ -41,8 +41,8 @@ public class XXServiceResourceElementValue extends XXDBBase implements Serializa
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXServiceResourceElementValueSEQ", sequenceName = "XXServiceResourceElementValueSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXServiceResourceElementValueSEQ")
+	@SequenceGenerator(name = "X_SERVICE_RES_EL_VAL_SEQ", sequenceName = "X_SERVICE_RES_EL_VAL_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_SERVICE_RES_EL_VAL_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
index c8a9d35..4e764d3 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTag.java
@@ -42,8 +42,8 @@ public class XXTag extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXTagSEQ", sequenceName = "XXTagSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTagSEQ")
+	@SequenceGenerator(name = "X_TAG_SEQ", sequenceName = "X_TAG_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_TAG_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
index cbbc102..c878380 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttribute.java
@@ -41,8 +41,8 @@ public class XXTagAttribute extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXTagAttributeSEQ", sequenceName = "XXTagAttributeSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTagAttributeSEQ")
+	@SequenceGenerator(name = "X_TAG_ATTR_SEQ", sequenceName = "X_TAG_ATTR_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_TAG_ATTR_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
index acf6697..c0e02e4 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagAttributeDef.java
@@ -41,8 +41,8 @@ public class XXTagAttributeDef extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXTagAttributeDefSEQ", sequenceName = "XXTagAttributeDefSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTagAttributeDefSEQ")
+	@SequenceGenerator(name = "X_SERVICE_RESOURCE_ELEMENT_SEQ", sequenceName = "X_SERVICE_RESOURCE_ELEMENT_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_SERVICE_RESOURCE_ELEMENT_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
index 5a3df65..40d5afb 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagDef.java
@@ -42,8 +42,8 @@ public class XXTagDef extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXTagDefSEQ", sequenceName = "XXTagDefSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTagDefSEQ")
+	@SequenceGenerator(name = "X_TAG_DEF_SEQ", sequenceName = "X_TAG_DEF_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_TAG_DEF_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java b/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
index 98f2355..b637f7b 100644
--- a/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
+++ b/security-admin/src/main/java/org/apache/ranger/entity/XXTagResourceMap.java
@@ -41,8 +41,8 @@ public class XXTagResourceMap extends XXDBBase implements Serializable {
 	private static final long serialVersionUID = 1L;
 
 	@Id
-	@SequenceGenerator(name = "XXTagResourceMapSEQ", sequenceName = "XXTagResourceMapSEQ", allocationSize = 1)
-	@GeneratedValue(strategy = GenerationType.AUTO, generator = "XXTagResourceMapSEQ")
+	@SequenceGenerator(name = "X_TAG_RESOURCE_MAP_SEQ", sequenceName = "X_TAG_RESOURCE_MAP_SEQ", allocationSize = 1)
+	@GeneratedValue(strategy = GenerationType.AUTO, generator = "X_TAG_RESOURCE_MAP_SEQ")
 	@Column(name = "id")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/f5245892/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
index df3fa1b..ee92291 100644
--- a/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
+++ b/security-admin/src/main/java/org/apache/ranger/service/RangerServiceDefServiceBase.java
@@ -162,7 +162,7 @@ public abstract class RangerServiceDefServiceBase<T extends XXServiceDefBase, V
 		xObj.setImplclassname(vObj.getImplClass());
 		xObj.setLabel(vObj.getLabel());
 		xObj.setDescription(vObj.getDescription());
-		xObj.setOptions(mapToJsonString(vObj.getOptions()));
+		xObj.setDefOptions(mapToJsonString(vObj.getOptions()));
 		xObj.setRbkeylabel(vObj.getRbKeyLabel());
 		xObj.setRbkeydescription(vObj.getRbKeyDescription());
 		xObj.setIsEnabled(vObj.getIsEnabled());
@@ -178,7 +178,7 @@ public abstract class RangerServiceDefServiceBase<T extends XXServiceDefBase, V
 		vObj.setImplClass(xObj.getImplclassname());
 		vObj.setLabel(xObj.getLabel());
 		vObj.setDescription(xObj.getDescription());
-		vObj.setOptions(jsonStringToMap(xObj.getOptions()));
+		vObj.setOptions(jsonStringToMap(xObj.getDefOptions()));
 		vObj.setRbKeyLabel(xObj.getRbkeylabel());
 		vObj.setRbKeyDescription(xObj.getRbkeydescription());
 		vObj.setIsEnabled(xObj.getIsEnabled());


Mime
View raw message