This is an automated email from the ASF dual-hosted git repository.
madhan pushed a commit to branch RANGER-3923
in repository https://gitbox.apache.org/repos/asf/ranger.git
The following commit(s) were added to refs/heads/RANGER-3923 by this push:
new de4a379b2 RANGER-4624: database schema updates to support GDS
de4a379b2 is described below
commit de4a379b22221670499862939ce0581f1a2eec95
Author: Monika Kachhadiya <[email protected]>
AuthorDate: Thu Dec 21 10:27:53 2023 -0800
RANGER-4624: database schema updates to support GDS
Signed-off-by: Madhan Neethiraj <[email protected]>
---
.../optimized/current/ranger_core_db_mysql.sql | 2 +
.../patches/071-alter-x_service_version_info.sql | 50 ++++++++++++++++++
.../mysql/patches/072-alter-x_access_type_def.sql | 31 +++++++++++
.../optimized/current/ranger_core_db_postgres.sql | 2 +
.../patches/071-alter-x_service_version_info.sql | 60 ++++++++++++++++++++++
.../patches/072-alter-x_access_type_def.sql | 39 ++++++++++++++
6 files changed, 184 insertions(+)
diff --git a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
index 1e0fe8745..fa72ef2ea 100644
--- a/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
+++ b/security-admin/db/mysql/optimized/current/ranger_core_db_mysql.sql
@@ -2048,6 +2048,8 @@ INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('068',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('069',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('070',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
+INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('071',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
+INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('072',UTC_TIMESTAMP(),'Ranger 3.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('DB_PATCHES',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('J10001',UTC_TIMESTAMP(),'Ranger 1.0.0',UTC_TIMESTAMP(),'localhost','Y');
diff --git
a/security-admin/db/mysql/patches/071-alter-x_service_version_info.sql
b/security-admin/db/mysql/patches/071-alter-x_service_version_info.sql
new file mode 100644
index 000000000..41e8f358d
--- /dev/null
+++ b/security-admin/db/mysql/patches/071-alter-x_service_version_info.sql
@@ -0,0 +1,50 @@
+-- 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 add_gds_version_x_service_version_info;
+
+delimiter ;;
+create procedure add_gds_version_x_service_version_info() begin
+
+if not exists (select * from information_schema.columns where
table_schema=database() and table_name = 'x_service_version_info' and
column_name='gds_version') then
+ ALTER TABLE x_service_version_info ADD gds_version bigint(20) NOT NULL
DEFAULT 0;
+end if;
+
+end;;
+
+delimiter ;
+
+call add_gds_version_x_service_version_info();
+
+drop procedure if exists add_gds_version_x_service_version_info;
+
+
+
+drop procedure if exists add_gds_update_time_x_service_version_info;
+
+delimiter ;;
+create procedure add_gds_update_time_x_service_version_info() begin
+
+if not exists (select * from information_schema.columns where
table_schema=database() and table_name = 'x_service_version_info' and
column_name='gds_update_time') then
+ ALTER TABLE x_service_version_info ADD gds_update_time datetime NULL
DEFAULT NULL;
+end if;
+
+end;;
+
+delimiter ;
+
+call add_gds_update_time_x_service_version_info();
+
+drop procedure if exists add_gds_update_time_x_service_version_info;
\ No newline at end of file
diff --git a/security-admin/db/mysql/patches/072-alter-x_access_type_def.sql
b/security-admin/db/mysql/patches/072-alter-x_access_type_def.sql
new file mode 100644
index 000000000..90e2ed487
--- /dev/null
+++ b/security-admin/db/mysql/patches/072-alter-x_access_type_def.sql
@@ -0,0 +1,31 @@
+-- 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 add_category_x_access_type_def;
+
+delimiter ;;
+create procedure add_category_x_access_type_def() begin
+
+if not exists (select * from information_schema.columns where
table_schema=database() and table_name = 'x_access_type_def' and
column_name='category') then
+ ALTER TABLE x_access_type_def ADD category smallint DEFAULT NULL;
+end if;
+
+end;;
+
+delimiter ;
+
+call add_category_x_access_type_def();
+
+drop procedure if exists add_category_x_access_type_def;
\ No newline at end of file
diff --git
a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
index 83286a952..e177d44d7 100644
--- a/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
+++ b/security-admin/db/postgres/optimized/current/ranger_core_db_postgres.sql
@@ -2151,6 +2151,8 @@ INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('068',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('069',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('070',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
+INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('071',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
+INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('072',current_timestamp,'Ranger 3.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_db_version_h
(version,inst_at,inst_by,updated_at,updated_by,active) VALUES
('DB_PATCHES',current_timestamp,'Ranger
1.0.0',current_timestamp,'localhost','Y');
INSERT INTO x_user_module_perm
(user_id,module_id,create_time,update_time,added_by_id,upd_by_id,is_allowed)
VALUES
diff --git
a/security-admin/db/postgres/patches/071-alter-x_service_version_info.sql
b/security-admin/db/postgres/patches/071-alter-x_service_version_info.sql
new file mode 100644
index 000000000..0509f011e
--- /dev/null
+++ b/security-admin/db/postgres/patches/071-alter-x_service_version_info.sql
@@ -0,0 +1,60 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+
+
+select 'delimiter start';
+CREATE OR REPLACE FUNCTION add_gds_version_x_service_version_info()
+RETURNS void AS $$
+DECLARE
+ v_column_exists integer := 0;
+BEGIN
+ select count(*) into v_column_exists from pg_attribute where attrelid
in(select oid from pg_class where relname='x_service_version_info') and
attname='gds_version';
+ IF v_column_exists = 0 THEN
+ ALTER TABLE x_service_version_info ADD COLUMN gds_version bigint NOT NULL
DEFAULT '0';
+ END IF;
+
+END;
+$$ LANGUAGE plpgsql;
+select 'delimiter end';
+
+select add_gds_version_x_service_version_info();
+select 'delimiter end';
+commit;
+
+
+
+select 'delimiter start';
+CREATE OR REPLACE FUNCTION add_gds_update_time_x_service_version_info()
+RETURNS void AS $$
+DECLARE
+ v_column_exists integer := 0;
+BEGIN
+ select count(*) into v_column_exists from pg_attribute where attrelid
in(select oid from pg_class where relname='x_service_version_info') and
attname='gds_update_time';
+ IF v_column_exists = 0 THEN
+ ALTER TABLE x_service_version_info ADD COLUMN gds_update_time TIMESTAMP
DEFAULT NULL;
+ END IF;
+
+END;
+$$ LANGUAGE plpgsql;
+select 'delimiter end';
+
+select add_gds_update_time_x_service_version_info();
+select 'delimiter end';
+commit;
+
+
+
+
diff --git a/security-admin/db/postgres/patches/072-alter-x_access_type_def.sql
b/security-admin/db/postgres/patches/072-alter-x_access_type_def.sql
new file mode 100644
index 000000000..e22a5c700
--- /dev/null
+++ b/security-admin/db/postgres/patches/072-alter-x_access_type_def.sql
@@ -0,0 +1,39 @@
+-- Licensed to the Apache Software Foundation (ASF) under one or more
+-- contributor license agreements. See the NOTICE file distributed with
+-- this work for additional information regarding copyright ownership.
+-- The ASF licenses this file to You under the Apache License, Version 2.0
+-- (the "License"); you may not use this file except in compliance with
+-- the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+
+
+select 'delimiter start';
+CREATE OR REPLACE FUNCTION add_category_x_access_type_def()
+RETURNS void AS $$
+DECLARE
+ v_column_exists integer := 0;
+BEGIN
+ select count(*) into v_column_exists from pg_attribute where attrelid
in(select oid from pg_class where relname='x_access_type_def') and
attname='category';
+ IF v_column_exists = 0 THEN
+ ALTER TABLE x_access_type_def ADD COLUMN category SMALLINT DEFAULT NULL NULL;
+ END IF;
+
+END;
+$$ LANGUAGE plpgsql;
+select 'delimiter end';
+
+select add_category_x_access_type_def();
+select 'delimiter end';
+commit;
+
+
+
+