RANGER-239: Support JDBC based SQL invocation for setup process
Project: http://git-wip-us.apache.org/repos/asf/incubator-ranger/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ranger/commit/9c2f0d1f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ranger/tree/9c2f0d1f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ranger/diff/9c2f0d1f Branch: refs/heads/master Commit: 9c2f0d1fb722dfcc3155ee928f0ef2739a9cc79f Parents: 1283c96 Author: vel <[email protected]> Authored: Thu Feb 19 15:05:10 2015 -0500 Committer: vel <[email protected]> Committed: Thu Feb 19 15:05:10 2015 -0500 ---------------------------------------------------------------------- agents-common/pom.xml | 5 + .../main/java/org/apache/util/sql/Jisql.java | 6 +- security-admin/db/create_dbversion_catalog.sql | 24 - security-admin/db/create_dev_user.sh | 35 - security-admin/db/create_dev_user.sql | 21 - security-admin/db/init/backup_mysql_db.sh | 34 - .../db/init/create_dev_backup_mysql.sh | 17 - .../db/init/create_dev_backup_mysql_loaded.sh | 17 - security-admin/db/init/create_xa_core_db.sh | 30 - security-admin/db/init/mysql_seed_data.sql | 40 - security-admin/db/init/reset_db.sh | 34 - security-admin/db/init/reset_db_with_seed.sh | 42 - security-admin/db/init/schema_mysql.sql | 490 ------------ .../db/mysql/create_dbversion_catalog.sql | 24 + security-admin/db/mysql/create_dev_user.sh | 35 + security-admin/db/mysql/create_dev_user.sql | 21 + security-admin/db/mysql/init/backup_mysql_db.sh | 34 + .../db/mysql/init/create_dev_backup_mysql.sh | 17 + .../init/create_dev_backup_mysql_loaded.sh | 17 + .../db/mysql/init/create_xa_core_db.sh | 30 + .../db/mysql/init/mysql_seed_data.sql | 40 + security-admin/db/mysql/init/reset_db.sh | 34 + .../db/mysql/init/reset_db_with_seed.sh | 42 + security-admin/db/mysql/init/schema_mysql.sql | 490 ++++++++++++ .../db/mysql/patches/001-groupsource.sql | 34 + .../db/mysql/patches/002-policyname.sql | 37 + .../db/mysql/patches/003-knoxrepo.sql | 48 ++ .../db/mysql/patches/004-assetconfigsize.sql | 31 + .../db/mysql/patches/005-xtrxlogcolumnsize.sql | 34 + .../patches/006-createdefaultpublicgroup.sql | 34 + .../mysql/patches/007-updateBlankPolicyName.sql | 186 +++++ .../mysql/patches/008-removeTrailingSlash.sql | 144 ++++ .../db/mysql/patches/009-updated_schema.sql | 416 ++++++++++ security-admin/db/mysql/reset_asset.sql | 19 + security-admin/db/mysql/reset_audit_mysql.sh | 44 ++ security-admin/db/mysql/reset_core_mysql.sh | 44 ++ security-admin/db/mysql/resetdb_dev_mysql.sh | 137 ++++ security-admin/db/mysql/xa_audit_db.sql | 82 ++ security-admin/db/mysql/xa_core_db.sql | 754 ++++++++++++++++++ security-admin/db/mysql/xa_db.sql | 778 +++++++++++++++++++ security-admin/db/mysql/xa_db_bare.sql | 15 + .../db/oracle/patches/001-groupsource.sql | 3 +- .../db/oracle/patches/002-policyname.sql | 3 +- .../db/oracle/patches/003-knoxrepo.sql | 3 +- .../patches/006-createdefaultpublicgroup.sql | 3 +- .../db/oracle/patches/009-updated_schema.sql | 407 ++++++++++ .../db/oracle/reset_audit_db_oracle.sql | 71 ++ .../db/oracle/reset_core_db_oracle.sql | 114 +++ security-admin/db/oracle/xa_audit_db_oracle.sql | 56 +- security-admin/db/oracle/xa_core_db_oracle.sql | 136 +--- security-admin/db/patches/001-groupsource.sql | 34 - security-admin/db/patches/002-policyname.sql | 37 - security-admin/db/patches/003-knoxrepo.sql | 48 -- .../db/patches/004-assetconfigsize.sql | 31 - .../db/patches/005-xtrxlogcolumnsize.sql | 34 - .../db/patches/006-createdefaultpublicgroup.sql | 34 - .../db/patches/007-updateBlankPolicyName.sql | 186 ----- .../db/patches/008-removeTrailingSlash.sql | 144 ---- .../db/patches/009-updated_schema.sql | 419 ---------- security-admin/db/reset_asset.sql | 19 - security-admin/db/reset_audit_mysql.sh | 44 -- security-admin/db/reset_core_mysql.sh | 44 -- security-admin/db/resetdb_dev_mysql.sh | 137 ---- security-admin/db/xa_audit_db.sql | 82 -- security-admin/db/xa_core_db.sql | 754 ------------------ security-admin/db/xa_db.sql | 778 ------------------- security-admin/db/xa_db_bare.sql | 15 - security-admin/pom.xml | 2 + security-admin/scripts/db_setup.py | 757 ++++++++++++++++++ security-admin/scripts/install.properties | 15 +- security-admin/scripts/setup.sh | 62 +- .../apache/ranger/entity/XXEnumElementDef.java | 4 +- .../org/apache/ranger/entity/XXResourceDef.java | 2 +- src/main/assembly/admin-web.xml | 1 + 74 files changed, 5039 insertions(+), 3856 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/agents-common/pom.xml ---------------------------------------------------------------------- diff --git a/agents-common/pom.xml b/agents-common/pom.xml index ede7b9d..021aad1 100644 --- a/agents-common/pom.xml +++ b/agents-common/pom.xml @@ -60,6 +60,11 @@ <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-jaxrs</artifactId> + <version>${codehaus.jackson.version}</version> + </dependency> <dependency> <groupId>security_plugins.ranger-plugins-audit</groupId> <artifactId>ranger-plugins-audit</artifactId> http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/jisql/src/main/java/org/apache/util/sql/Jisql.java ---------------------------------------------------------------------- diff --git a/jisql/src/main/java/org/apache/util/sql/Jisql.java b/jisql/src/main/java/org/apache/util/sql/Jisql.java index f3fab71..c3ba5a6 100644 --- a/jisql/src/main/java/org/apache/util/sql/Jisql.java +++ b/jisql/src/main/java/org/apache/util/sql/Jisql.java @@ -396,6 +396,7 @@ public class Jisql { } if(connectString.toLowerCase().startsWith("jdbc:oracle") && inputFileName!=null){ if (trimmedLine.startsWith("/") ||trimmedLine.length()<2) { + commandTerminator=";"; continue; } } @@ -644,8 +645,9 @@ public class Jisql { throw new Exception("user name must exist"); if ((password == null) && (passwordFileName == null)) { - Console console = System.console(); - password = new String( console.readPassword("Password (hit enter for no password): ") ); + password=""; + //Console console = System.console(); + //password = new String( console.readPassword("Password (hit enter for no password): ") ); } else if (password == null) { File passwordFile = null; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/create_dbversion_catalog.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/create_dbversion_catalog.sql b/security-admin/db/create_dbversion_catalog.sql deleted file mode 100644 index 9c90633..0000000 --- a/security-admin/db/create_dbversion_catalog.sql +++ /dev/null @@ -1,24 +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 table if not exists x_db_version_h ( - id bigint not null auto_increment primary key, - version varchar(64) not null, - inst_at timestamp not null default current_timestamp, - inst_by varchar(256) not null, - updated_at timestamp not null, - updated_by varchar(256) not null, - active ENUM('Y', 'N') default 'Y' -) ; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/create_dev_user.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/create_dev_user.sh b/security-admin/db/create_dev_user.sh deleted file mode 100755 index a59e264..0000000 --- a/security-admin/db/create_dev_user.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -# 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. - -# -# Script to reset mysql database -# - -if [ $# -lt 1 ]; then - echo "Usage: $0 <db_root_password> [db_host]" - exit 1 -fi - -db_root_password=$1 -db_host="localhost" -if [ "$2" != "" ]; then - db_host="$2" -fi - -echo "Creating user ... " -set -x -mysql -u root --password=$db_root_password < create_dev_user.sql http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/create_dev_user.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/create_dev_user.sql b/security-admin/db/create_dev_user.sql deleted file mode 100644 index bf475d0..0000000 --- a/security-admin/db/create_dev_user.sql +++ /dev/null @@ -1,21 +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 user 'xaadmin'@'%' identified by 'xaadmin'; -GRANT ALL ON *.* TO 'xaadmin'@'localhost' IDENTIFIED BY 'xaadmin'; -grant all privileges on *.* to 'xaadmin'@'%' with grant option; -grant all privileges on *.* to 'xaadmin'@'localhost' with grant option; -FLUSH PRIVILEGES; - http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/backup_mysql_db.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/init/backup_mysql_db.sh b/security-admin/db/init/backup_mysql_db.sh deleted file mode 100755 index ef66140..0000000 --- a/security-admin/db/init/backup_mysql_db.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# 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. - -# -# Script to reset mysql database -# - -if [ $# -lt 3 ]; then - echo "Usage: $0 <db_user> <db_password> <db_database> <output file>" - exit 1 -fi - -db_user=$1 -db_password=$2 -db_database=$3 -outfile=$4 - -echo "Exporting $db_database ... " -mysqldump -u $db_user --password=$db_password --add-drop-database --database $db_database > $outfile -echo "Check output file $outfile" http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/create_dev_backup_mysql.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/init/create_dev_backup_mysql.sh b/security-admin/db/init/create_dev_backup_mysql.sh deleted file mode 100755 index db2e2a7..0000000 --- a/security-admin/db/init/create_dev_backup_mysql.sh +++ /dev/null @@ -1,17 +0,0 @@ -./backup_mysql_db.sh xaadmin xaadmin xa_db ../xa_db_bare.sql - -# 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. - http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/create_dev_backup_mysql_loaded.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/init/create_dev_backup_mysql_loaded.sh b/security-admin/db/init/create_dev_backup_mysql_loaded.sh deleted file mode 100755 index c1905b6..0000000 --- a/security-admin/db/init/create_dev_backup_mysql_loaded.sh +++ /dev/null @@ -1,17 +0,0 @@ -./backup_mysql_db.sh xaadmin xaadmin xa_db ../xa_db.sql - -# 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. - http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/create_xa_core_db.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/init/create_xa_core_db.sh b/security-admin/db/init/create_xa_core_db.sh deleted file mode 100755 index 3c9483f..0000000 --- a/security-admin/db/init/create_xa_core_db.sh +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/bash - -# 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. - -# -# Script to reset mysql database -# - - -db_user=xaadmin -db_password=xaadmin -db_database=xa_db -outfile=../xa_core_db.sql - -echo "Exporting $db_database ... " -mysqldump -u $db_user --password=$db_password $db_database > $outfile -echo "Check output file $outfile" http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/mysql_seed_data.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/init/mysql_seed_data.sql b/security-admin/db/init/mysql_seed_data.sql deleted file mode 100644 index 8f992b1..0000000 --- a/security-admin/db/init/mysql_seed_data.sql +++ /dev/null @@ -1,40 +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. - -insert into x_portal_user ( - CREATE_TIME, UPDATE_TIME, - FIRST_NAME, LAST_NAME, PUB_SCR_NAME, - LOGIN_ID, PASSWORD, EMAIL, STATUS -) values ( - now(), now(), - 'Admin', '', 'Admin', - 'admin', 'ceb4f32325eda6142bd65215f4c0f371', '', 1 -); -SET @user_id:= last_insert_id(); - -insert into x_portal_user_role ( - CREATE_TIME, UPDATE_TIME, - USER_ID, USER_ROLE, STATUS -) values ( - now(), now(), - @user_id, 'ROLE_SYS_ADMIN', 1 -); -SET @user_role_id:= last_insert_id(); - - - -DROP TABLE IF EXISTS `vx_trx_log`; -DROP VIEW IF EXISTS `vx_trx_log`; -CREATE VIEW `vx_trx_log` AS select `x_trx_log`.`id` AS `id`,`x_trx_log`.`create_time` AS `create_time`,`x_trx_log`.`update_time` AS `update_time`,`x_trx_log`.`added_by_id` AS `added_by_id`,`x_trx_log`.`upd_by_id` AS `upd_by_id`,`x_trx_log`.`class_type` AS `class_type`,`x_trx_log`.`object_id` AS `object_id`,`x_trx_log`.`parent_object_id` AS `parent_object_id`,`x_trx_log`.`parent_object_class_type` AS `parent_object_class_type`,`x_trx_log`.`attr_name` AS `attr_name`,`x_trx_log`.`parent_object_name` AS `parent_object_name`,`x_trx_log`.`object_name` AS `object_name`,`x_trx_log`.`prev_val` AS `prev_val`,`x_trx_log`.`new_val` AS `new_val`,`x_trx_log`.`trx_id` AS `trx_id`,`x_trx_log`.`action` AS `action`,`x_trx_log`.`sess_id` AS `sess_id`,`x_trx_log`.`req_id` AS `req_id`,`x_trx_log`.`sess_type` AS `sess_type` from `x_trx_log` group by `x_trx_log`.`trx_id` http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/reset_db.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/init/reset_db.sh b/security-admin/db/init/reset_db.sh deleted file mode 100755 index 8a7632d..0000000 --- a/security-admin/db/init/reset_db.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# 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 [ $# -ne 3 ]; then - echo "Usage: $0 <db_user> <db_password> <db_database> [db_host]" - exit 1 -fi - -db_user=$1 -db_password=$2 -db_database=$3 - -set -x -#First drop the database and recreate i -echo "y" | mysqladmin -u $db_user -p$db_password drop $db_database -mysqladmin -u $db_user -p$db_password create $db_database - -#Create the schema -mysql -u $db_user -p$db_password $db_database < schema_mysql.sql - http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/reset_db_with_seed.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/init/reset_db_with_seed.sh b/security-admin/db/init/reset_db_with_seed.sh deleted file mode 100755 index 5670922..0000000 --- a/security-admin/db/init/reset_db_with_seed.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# 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 [ $# -ne 3 ]; then - echo "Usage: $0 <db_user> <db_password> <db_database> [db_host]" - exit 1 -fi - -db_user=$1 -db_password=$2 -db_database=$3 - -#db_user=cignifi -#db_password=cignifi -#db_database=cignifi_dev - - -set -x -#First drop the database and recreate i -echo "y" | mysqladmin -u $db_user -p$db_password drop $db_database -mysqladmin -u $db_user -p$db_password create $db_database - -#Create the schema -mysql -u $db_user -p$db_password $db_database < schema_mysql.sql - -#Add seed users -mysql -u $db_user -p$db_password $db_database < mysql_seed_data.sql - http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/init/schema_mysql.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/init/schema_mysql.sql b/security-admin/db/init/schema_mysql.sql deleted file mode 100644 index 1dd7420..0000000 --- a/security-admin/db/init/schema_mysql.sql +++ /dev/null @@ -1,490 +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 @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; -SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; -SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; - -drop table if exists x_db_base; -create table x_db_base ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_auth_sess; -create table x_auth_sess ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - login_id VARCHAR (767) NOT NULL, - user_id BIGINT , - ext_sess_id VARCHAR (512) , - auth_time DATETIME NOT NULL, - auth_status INT NOT NULL DEFAULT 0, - auth_type INT NOT NULL DEFAULT 0, - auth_provider INT NOT NULL DEFAULT 0, - device_type INT NOT NULL DEFAULT 0, - req_ip VARCHAR (48) NOT NULL, - req_ua VARCHAR (1024) , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_portal_user; -create table x_portal_user ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - first_name VARCHAR (1022) , - last_name VARCHAR (1022) , - pub_scr_name VARCHAR (2048) , - login_id VARCHAR (767) , - password VARCHAR (512) NOT NULL, - email VARCHAR (512) , - status INT NOT NULL DEFAULT 0, - user_src INT NOT NULL DEFAULT 0, - notes VARCHAR (4000) , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_portal_user_role; -create table x_portal_user_role ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - user_id BIGINT NOT NULL, - user_role VARCHAR (128) , - status INT NOT NULL DEFAULT 0, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_asset; -create table x_asset ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - asset_name VARCHAR (1024) NOT NULL, - descr VARCHAR (4000) NOT NULL, - act_status INT NOT NULL DEFAULT 0, - asset_type INT NOT NULL DEFAULT 0, - config TEXT , - sup_native TINYINT (1) NOT NULL DEFAULT 0, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_resource; -create table x_resource ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - res_name VARCHAR (4000) , - descr VARCHAR (4000) , - res_type INT NOT NULL DEFAULT 0, - asset_id BIGINT NOT NULL, - parent_id BIGINT , - parent_path VARCHAR (4000) , - is_encrypt INT NOT NULL DEFAULT 0, - is_recursive INT NOT NULL DEFAULT 0, - res_group VARCHAR (1024) , - res_dbs TEXT , - res_tables TEXT , - res_col_fams TEXT , - res_cols TEXT , - res_udfs TEXT , - res_status INT NOT NULL DEFAULT 1, - table_type INT NOT NULL DEFAULT 0, - col_type INT NOT NULL DEFAULT 0, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_cred_store; -create table x_cred_store ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - store_name VARCHAR (1024) NOT NULL, - descr VARCHAR (4000) NOT NULL, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_group; -create table x_group ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - group_name VARCHAR (1024) NOT NULL, - descr VARCHAR (4000) NOT NULL, - status INT NOT NULL DEFAULT 0, - group_type INT NOT NULL DEFAULT 0, - cred_store_id BIGINT , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_user; -create table x_user ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - user_name VARCHAR (1024) NOT NULL, - descr VARCHAR (4000) NOT NULL, - status INT NOT NULL DEFAULT 0, - cred_store_id BIGINT , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_group_users; -create table x_group_users ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - group_name VARCHAR (1024) NOT NULL, - p_group_id BIGINT , - user_id BIGINT , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_group_groups; -create table x_group_groups ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - group_name VARCHAR (1024) NOT NULL, - p_group_id BIGINT , - group_id BIGINT , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_perm_map; -create table x_perm_map ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - perm_group VARCHAR (1024) , - res_id BIGINT , - group_id BIGINT , - user_id BIGINT , - perm_for INT NOT NULL DEFAULT 0, - perm_type INT NOT NULL DEFAULT 0, - is_recursive INT NOT NULL DEFAULT 0, - is_wild_card TINYINT (1) NOT NULL DEFAULT 1, - grant_revoke TINYINT (1) NOT NULL DEFAULT 1, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_audit_map; -create table x_audit_map ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - res_id BIGINT , - group_id BIGINT , - user_id BIGINT , - audit_type INT NOT NULL DEFAULT 0, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_policy_export_audit; -create table x_policy_export_audit ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - client_ip VARCHAR (255) NOT NULL, - agent_id VARCHAR (255) , - req_epoch BIGINT NOT NULL, - last_updated DATETIME , - repository_name VARCHAR (1024) , - exported_json TEXT , - http_ret_code INT NOT NULL DEFAULT 0, - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists x_trx_log; -create table x_trx_log ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - class_type INT NOT NULL DEFAULT 0, - object_id BIGINT , - parent_object_id BIGINT , - parent_object_class_type INT NOT NULL DEFAULT 0, - parent_object_name VARCHAR (1024) , - object_name VARCHAR (1024) , - attr_name VARCHAR (255) , - prev_val VARCHAR (1024) , - new_val VARCHAR (1024) , - trx_id VARCHAR (1024) , - action VARCHAR (255) , - sess_id VARCHAR (512) , - req_id VARCHAR (30) , - sess_type VARCHAR (30) , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - -drop table if exists xa_access_audit; -create table xa_access_audit ( - id BIGINT NOT NULL AUTO_INCREMENT, - create_time DATETIME , - update_time DATETIME , - added_by_id BIGINT , - upd_by_id BIGINT , - audit_type INT NOT NULL DEFAULT 0, - access_result INT DEFAULT 0, - access_type VARCHAR (255) , - acl_enforcer VARCHAR (255) , - agent_id VARCHAR (255) , - client_ip VARCHAR (255) , - client_type VARCHAR (255) , - policy_id BIGINT DEFAULT 0, - repo_name VARCHAR (255) , - repo_type INT DEFAULT 0, - result_reason VARCHAR (255) , - session_id VARCHAR (255) , - event_time DATETIME , - request_user VARCHAR (255) , - action VARCHAR (2000) , - request_data VARCHAR (2000) , - resource_path VARCHAR (2000) , - resource_type VARCHAR (255) , - PRIMARY KEY(id) -) ENGINE=InnoDB DEFAULT CHARSET=latin1; - - -ALTER TABLE x_db_base ADD ( - CONSTRAINT x_db_base_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_db_base ADD ( - CONSTRAINT x_db_base_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_auth_sess ADD ( - CONSTRAINT x_auth_sess_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_auth_sess ADD ( - CONSTRAINT x_auth_sess_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_auth_sess ADD ( - CONSTRAINT x_auth_sess_FK_user_id FOREIGN KEY (user_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_portal_user ADD ( - CONSTRAINT x_portal_user_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_portal_user ADD ( - CONSTRAINT x_portal_user_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_portal_user_role ADD ( - CONSTRAINT x_portal_user_role_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_portal_user_role ADD ( - CONSTRAINT x_portal_user_role_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_portal_user_role ADD ( - CONSTRAINT x_portal_user_role_FK_user_id FOREIGN KEY (user_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_asset ADD ( - CONSTRAINT x_asset_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_asset ADD ( - CONSTRAINT x_asset_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_resource ADD ( - CONSTRAINT x_resource_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_resource ADD ( - CONSTRAINT x_resource_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_resource ADD ( - CONSTRAINT x_resource_FK_asset_id FOREIGN KEY (asset_id) - REFERENCES x_asset (id)); -ALTER TABLE x_resource ADD ( - CONSTRAINT x_resource_FK_parent_id FOREIGN KEY (parent_id) - REFERENCES x_resource (id)); -ALTER TABLE x_cred_store ADD ( - CONSTRAINT x_cred_store_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_cred_store ADD ( - CONSTRAINT x_cred_store_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group ADD ( - CONSTRAINT x_group_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group ADD ( - CONSTRAINT x_group_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group ADD ( - CONSTRAINT x_group_FK_cred_store_id FOREIGN KEY (cred_store_id) - REFERENCES x_cred_store (id)); -ALTER TABLE x_user ADD ( - CONSTRAINT x_user_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_user ADD ( - CONSTRAINT x_user_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_user ADD ( - CONSTRAINT x_user_FK_cred_store_id FOREIGN KEY (cred_store_id) - REFERENCES x_cred_store (id)); -ALTER TABLE x_group_users ADD ( - CONSTRAINT x_group_users_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group_users ADD ( - CONSTRAINT x_group_users_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group_users ADD ( - CONSTRAINT x_group_users_FK_p_group_id FOREIGN KEY (p_group_id) - REFERENCES x_group (id)); -ALTER TABLE x_group_users ADD ( - CONSTRAINT x_group_users_FK_user_id FOREIGN KEY (user_id) - REFERENCES x_user (id)); -ALTER TABLE x_group_groups ADD ( - CONSTRAINT x_group_groups_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group_groups ADD ( - CONSTRAINT x_group_groups_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_group_groups ADD ( - CONSTRAINT x_group_groups_FK_p_group_id FOREIGN KEY (p_group_id) - REFERENCES x_group (id)); -ALTER TABLE x_group_groups ADD ( - CONSTRAINT x_group_groups_FK_group_id FOREIGN KEY (group_id) - REFERENCES x_group (id)); -ALTER TABLE x_perm_map ADD ( - CONSTRAINT x_perm_map_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_perm_map ADD ( - CONSTRAINT x_perm_map_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_perm_map ADD ( - CONSTRAINT x_perm_map_FK_res_id FOREIGN KEY (res_id) - REFERENCES x_resource (id)); -ALTER TABLE x_perm_map ADD ( - CONSTRAINT x_perm_map_FK_group_id FOREIGN KEY (group_id) - REFERENCES x_group (id)); -ALTER TABLE x_perm_map ADD ( - CONSTRAINT x_perm_map_FK_user_id FOREIGN KEY (user_id) - REFERENCES x_user (id)); -ALTER TABLE x_audit_map ADD ( - CONSTRAINT x_audit_map_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_audit_map ADD ( - CONSTRAINT x_audit_map_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_audit_map ADD ( - CONSTRAINT x_audit_map_FK_res_id FOREIGN KEY (res_id) - REFERENCES x_resource (id)); -ALTER TABLE x_audit_map ADD ( - CONSTRAINT x_audit_map_FK_group_id FOREIGN KEY (group_id) - REFERENCES x_group (id)); -ALTER TABLE x_audit_map ADD ( - CONSTRAINT x_audit_map_FK_user_id FOREIGN KEY (user_id) - REFERENCES x_user (id)); -ALTER TABLE x_policy_export_audit ADD ( - CONSTRAINT x_policy_export_audit_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_policy_export_audit ADD ( - CONSTRAINT x_policy_export_audit_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_trx_log ADD ( - CONSTRAINT x_trx_log_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE x_trx_log ADD ( - CONSTRAINT x_trx_log_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE xa_access_audit ADD ( - CONSTRAINT xa_access_audit_FK_added_by_id FOREIGN KEY (added_by_id) - REFERENCES x_portal_user (id)); -ALTER TABLE xa_access_audit ADD ( - CONSTRAINT xa_access_audit_FK_upd_by_id FOREIGN KEY (upd_by_id) - REFERENCES x_portal_user (id)); - -ALTER TABLE x_portal_user ADD ( - CONSTRAINT x_portal_user_UK_login_id UNIQUE (login_id(767)) ); -ALTER TABLE x_portal_user ADD ( - CONSTRAINT x_portal_user_UK_email UNIQUE (email(512)) ); - -ALTER TABLE x_db_base ADD (INDEX x_db_base_cr_time (create_time)); -ALTER TABLE x_db_base ADD (INDEX x_db_base_up_time (update_time)); -ALTER TABLE x_auth_sess ADD (INDEX x_auth_sess_cr_time (create_time)); -ALTER TABLE x_auth_sess ADD (INDEX x_auth_sess_up_time (update_time)); -ALTER TABLE x_portal_user ADD (INDEX x_portal_user_cr_time (create_time)); -ALTER TABLE x_portal_user ADD (INDEX x_portal_user_up_time (update_time)); -ALTER TABLE x_portal_user ADD (INDEX x_portal_user_name (first_name(767))); -ALTER TABLE x_portal_user ADD (INDEX x_portal_user_email (email(512))); -ALTER TABLE x_portal_user_role ADD (INDEX x_portal_user_role_cr_time (create_time)); -ALTER TABLE x_portal_user_role ADD (INDEX x_portal_user_role_up_time (update_time)); -ALTER TABLE x_asset ADD (INDEX x_asset_cr_time (create_time)); -ALTER TABLE x_asset ADD (INDEX x_asset_up_time (update_time)); -ALTER TABLE x_resource ADD (INDEX x_resource_cr_time (create_time)); -ALTER TABLE x_resource ADD (INDEX x_resource_up_time (update_time)); -ALTER TABLE x_cred_store ADD (INDEX x_cred_store_cr_time (create_time)); -ALTER TABLE x_cred_store ADD (INDEX x_cred_store_up_time (update_time)); -ALTER TABLE x_group ADD (INDEX x_group_cr_time (create_time)); -ALTER TABLE x_group ADD (INDEX x_group_up_time (update_time)); -ALTER TABLE x_user ADD (INDEX x_user_cr_time (create_time)); -ALTER TABLE x_user ADD (INDEX x_user_up_time (update_time)); -ALTER TABLE x_group_users ADD (INDEX x_group_users_cr_time (create_time)); -ALTER TABLE x_group_users ADD (INDEX x_group_users_up_time (update_time)); -ALTER TABLE x_group_groups ADD (INDEX x_group_groups_cr_time (create_time)); -ALTER TABLE x_group_groups ADD (INDEX x_group_groups_up_time (update_time)); -ALTER TABLE x_perm_map ADD (INDEX x_perm_map_cr_time (create_time)); -ALTER TABLE x_perm_map ADD (INDEX x_perm_map_up_time (update_time)); -ALTER TABLE x_audit_map ADD (INDEX x_audit_map_cr_time (create_time)); -ALTER TABLE x_audit_map ADD (INDEX x_audit_map_up_time (update_time)); -ALTER TABLE x_policy_export_audit ADD (INDEX x_policy_export_audit_cr_time (create_time)); -ALTER TABLE x_policy_export_audit ADD (INDEX x_policy_export_audit_up_time (update_time)); -ALTER TABLE x_trx_log ADD (INDEX x_trx_log_cr_time (create_time)); -ALTER TABLE x_trx_log ADD (INDEX x_trx_log_up_time (update_time)); -ALTER TABLE xa_access_audit ADD (INDEX xa_access_audit_cr_time (create_time)); -ALTER TABLE xa_access_audit ADD (INDEX xa_access_audit_up_time (update_time)); -SET SQL_MODE=@OLD_SQL_MODE; -SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; -SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; -##champlain changes -ALTER TABLE `x_group` ADD `group_src` INT NOT NULL DEFAULT 0; -ALTER TABLE `x_resource` ADD `policy_name` VARCHAR( 500 ) NULL DEFAULT NULL; -ALTER TABLE `x_resource` ADD UNIQUE `x_resource_UK_policy_name` ( `policy_name` ); -ALTER TABLE `x_resource` ADD `res_topologies` TEXT NULL DEFAULT NULL ; -ALTER TABLE `x_resource` ADD `res_services` TEXT NULL DEFAULT NULL; -ALTER TABLE `x_perm_map` ADD `ip_address` TEXT NULL DEFAULT NULL; -ALTER TABLE `x_asset` CHANGE `config` `config` LONGTEXT NULL DEFAULT NULL ; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/create_dbversion_catalog.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/create_dbversion_catalog.sql b/security-admin/db/mysql/create_dbversion_catalog.sql new file mode 100644 index 0000000..9c90633 --- /dev/null +++ b/security-admin/db/mysql/create_dbversion_catalog.sql @@ -0,0 +1,24 @@ +-- 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 table if not exists x_db_version_h ( + id bigint not null auto_increment primary key, + version varchar(64) not null, + inst_at timestamp not null default current_timestamp, + inst_by varchar(256) not null, + updated_at timestamp not null, + updated_by varchar(256) not null, + active ENUM('Y', 'N') default 'Y' +) ; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/create_dev_user.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/create_dev_user.sh b/security-admin/db/mysql/create_dev_user.sh new file mode 100755 index 0000000..a59e264 --- /dev/null +++ b/security-admin/db/mysql/create_dev_user.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# 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. + +# +# Script to reset mysql database +# + +if [ $# -lt 1 ]; then + echo "Usage: $0 <db_root_password> [db_host]" + exit 1 +fi + +db_root_password=$1 +db_host="localhost" +if [ "$2" != "" ]; then + db_host="$2" +fi + +echo "Creating user ... " +set -x +mysql -u root --password=$db_root_password < create_dev_user.sql http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/create_dev_user.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/create_dev_user.sql b/security-admin/db/mysql/create_dev_user.sql new file mode 100644 index 0000000..bf475d0 --- /dev/null +++ b/security-admin/db/mysql/create_dev_user.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. + +create user 'xaadmin'@'%' identified by 'xaadmin'; +GRANT ALL ON *.* TO 'xaadmin'@'localhost' IDENTIFIED BY 'xaadmin'; +grant all privileges on *.* to 'xaadmin'@'%' with grant option; +grant all privileges on *.* to 'xaadmin'@'localhost' with grant option; +FLUSH PRIVILEGES; + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/backup_mysql_db.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/backup_mysql_db.sh b/security-admin/db/mysql/init/backup_mysql_db.sh new file mode 100755 index 0000000..ef66140 --- /dev/null +++ b/security-admin/db/mysql/init/backup_mysql_db.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# 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. + +# +# Script to reset mysql database +# + +if [ $# -lt 3 ]; then + echo "Usage: $0 <db_user> <db_password> <db_database> <output file>" + exit 1 +fi + +db_user=$1 +db_password=$2 +db_database=$3 +outfile=$4 + +echo "Exporting $db_database ... " +mysqldump -u $db_user --password=$db_password --add-drop-database --database $db_database > $outfile +echo "Check output file $outfile" http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/create_dev_backup_mysql.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/create_dev_backup_mysql.sh b/security-admin/db/mysql/init/create_dev_backup_mysql.sh new file mode 100755 index 0000000..db2e2a7 --- /dev/null +++ b/security-admin/db/mysql/init/create_dev_backup_mysql.sh @@ -0,0 +1,17 @@ +./backup_mysql_db.sh xaadmin xaadmin xa_db ../xa_db_bare.sql + +# 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. + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/create_dev_backup_mysql_loaded.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/create_dev_backup_mysql_loaded.sh b/security-admin/db/mysql/init/create_dev_backup_mysql_loaded.sh new file mode 100755 index 0000000..c1905b6 --- /dev/null +++ b/security-admin/db/mysql/init/create_dev_backup_mysql_loaded.sh @@ -0,0 +1,17 @@ +./backup_mysql_db.sh xaadmin xaadmin xa_db ../xa_db.sql + +# 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. + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/create_xa_core_db.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/create_xa_core_db.sh b/security-admin/db/mysql/init/create_xa_core_db.sh new file mode 100755 index 0000000..3c9483f --- /dev/null +++ b/security-admin/db/mysql/init/create_xa_core_db.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# 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. + +# +# Script to reset mysql database +# + + +db_user=xaadmin +db_password=xaadmin +db_database=xa_db +outfile=../xa_core_db.sql + +echo "Exporting $db_database ... " +mysqldump -u $db_user --password=$db_password $db_database > $outfile +echo "Check output file $outfile" http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/mysql_seed_data.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/mysql_seed_data.sql b/security-admin/db/mysql/init/mysql_seed_data.sql new file mode 100644 index 0000000..8f992b1 --- /dev/null +++ b/security-admin/db/mysql/init/mysql_seed_data.sql @@ -0,0 +1,40 @@ +-- 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. + +insert into x_portal_user ( + CREATE_TIME, UPDATE_TIME, + FIRST_NAME, LAST_NAME, PUB_SCR_NAME, + LOGIN_ID, PASSWORD, EMAIL, STATUS +) values ( + now(), now(), + 'Admin', '', 'Admin', + 'admin', 'ceb4f32325eda6142bd65215f4c0f371', '', 1 +); +SET @user_id:= last_insert_id(); + +insert into x_portal_user_role ( + CREATE_TIME, UPDATE_TIME, + USER_ID, USER_ROLE, STATUS +) values ( + now(), now(), + @user_id, 'ROLE_SYS_ADMIN', 1 +); +SET @user_role_id:= last_insert_id(); + + + +DROP TABLE IF EXISTS `vx_trx_log`; +DROP VIEW IF EXISTS `vx_trx_log`; +CREATE VIEW `vx_trx_log` AS select `x_trx_log`.`id` AS `id`,`x_trx_log`.`create_time` AS `create_time`,`x_trx_log`.`update_time` AS `update_time`,`x_trx_log`.`added_by_id` AS `added_by_id`,`x_trx_log`.`upd_by_id` AS `upd_by_id`,`x_trx_log`.`class_type` AS `class_type`,`x_trx_log`.`object_id` AS `object_id`,`x_trx_log`.`parent_object_id` AS `parent_object_id`,`x_trx_log`.`parent_object_class_type` AS `parent_object_class_type`,`x_trx_log`.`attr_name` AS `attr_name`,`x_trx_log`.`parent_object_name` AS `parent_object_name`,`x_trx_log`.`object_name` AS `object_name`,`x_trx_log`.`prev_val` AS `prev_val`,`x_trx_log`.`new_val` AS `new_val`,`x_trx_log`.`trx_id` AS `trx_id`,`x_trx_log`.`action` AS `action`,`x_trx_log`.`sess_id` AS `sess_id`,`x_trx_log`.`req_id` AS `req_id`,`x_trx_log`.`sess_type` AS `sess_type` from `x_trx_log` group by `x_trx_log`.`trx_id` http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/reset_db.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/reset_db.sh b/security-admin/db/mysql/init/reset_db.sh new file mode 100755 index 0000000..8a7632d --- /dev/null +++ b/security-admin/db/mysql/init/reset_db.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +# 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 [ $# -ne 3 ]; then + echo "Usage: $0 <db_user> <db_password> <db_database> [db_host]" + exit 1 +fi + +db_user=$1 +db_password=$2 +db_database=$3 + +set -x +#First drop the database and recreate i +echo "y" | mysqladmin -u $db_user -p$db_password drop $db_database +mysqladmin -u $db_user -p$db_password create $db_database + +#Create the schema +mysql -u $db_user -p$db_password $db_database < schema_mysql.sql + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/reset_db_with_seed.sh ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/reset_db_with_seed.sh b/security-admin/db/mysql/init/reset_db_with_seed.sh new file mode 100755 index 0000000..5670922 --- /dev/null +++ b/security-admin/db/mysql/init/reset_db_with_seed.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +# 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 [ $# -ne 3 ]; then + echo "Usage: $0 <db_user> <db_password> <db_database> [db_host]" + exit 1 +fi + +db_user=$1 +db_password=$2 +db_database=$3 + +#db_user=cignifi +#db_password=cignifi +#db_database=cignifi_dev + + +set -x +#First drop the database and recreate i +echo "y" | mysqladmin -u $db_user -p$db_password drop $db_database +mysqladmin -u $db_user -p$db_password create $db_database + +#Create the schema +mysql -u $db_user -p$db_password $db_database < schema_mysql.sql + +#Add seed users +mysql -u $db_user -p$db_password $db_database < mysql_seed_data.sql + http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/init/schema_mysql.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/init/schema_mysql.sql b/security-admin/db/mysql/init/schema_mysql.sql new file mode 100644 index 0000000..1dd7420 --- /dev/null +++ b/security-admin/db/mysql/init/schema_mysql.sql @@ -0,0 +1,490 @@ +-- 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 @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; + +drop table if exists x_db_base; +create table x_db_base ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_auth_sess; +create table x_auth_sess ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + login_id VARCHAR (767) NOT NULL, + user_id BIGINT , + ext_sess_id VARCHAR (512) , + auth_time DATETIME NOT NULL, + auth_status INT NOT NULL DEFAULT 0, + auth_type INT NOT NULL DEFAULT 0, + auth_provider INT NOT NULL DEFAULT 0, + device_type INT NOT NULL DEFAULT 0, + req_ip VARCHAR (48) NOT NULL, + req_ua VARCHAR (1024) , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_portal_user; +create table x_portal_user ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + first_name VARCHAR (1022) , + last_name VARCHAR (1022) , + pub_scr_name VARCHAR (2048) , + login_id VARCHAR (767) , + password VARCHAR (512) NOT NULL, + email VARCHAR (512) , + status INT NOT NULL DEFAULT 0, + user_src INT NOT NULL DEFAULT 0, + notes VARCHAR (4000) , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_portal_user_role; +create table x_portal_user_role ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + user_id BIGINT NOT NULL, + user_role VARCHAR (128) , + status INT NOT NULL DEFAULT 0, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_asset; +create table x_asset ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + asset_name VARCHAR (1024) NOT NULL, + descr VARCHAR (4000) NOT NULL, + act_status INT NOT NULL DEFAULT 0, + asset_type INT NOT NULL DEFAULT 0, + config TEXT , + sup_native TINYINT (1) NOT NULL DEFAULT 0, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_resource; +create table x_resource ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + res_name VARCHAR (4000) , + descr VARCHAR (4000) , + res_type INT NOT NULL DEFAULT 0, + asset_id BIGINT NOT NULL, + parent_id BIGINT , + parent_path VARCHAR (4000) , + is_encrypt INT NOT NULL DEFAULT 0, + is_recursive INT NOT NULL DEFAULT 0, + res_group VARCHAR (1024) , + res_dbs TEXT , + res_tables TEXT , + res_col_fams TEXT , + res_cols TEXT , + res_udfs TEXT , + res_status INT NOT NULL DEFAULT 1, + table_type INT NOT NULL DEFAULT 0, + col_type INT NOT NULL DEFAULT 0, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_cred_store; +create table x_cred_store ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + store_name VARCHAR (1024) NOT NULL, + descr VARCHAR (4000) NOT NULL, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_group; +create table x_group ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + group_name VARCHAR (1024) NOT NULL, + descr VARCHAR (4000) NOT NULL, + status INT NOT NULL DEFAULT 0, + group_type INT NOT NULL DEFAULT 0, + cred_store_id BIGINT , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_user; +create table x_user ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + user_name VARCHAR (1024) NOT NULL, + descr VARCHAR (4000) NOT NULL, + status INT NOT NULL DEFAULT 0, + cred_store_id BIGINT , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_group_users; +create table x_group_users ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + group_name VARCHAR (1024) NOT NULL, + p_group_id BIGINT , + user_id BIGINT , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_group_groups; +create table x_group_groups ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + group_name VARCHAR (1024) NOT NULL, + p_group_id BIGINT , + group_id BIGINT , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_perm_map; +create table x_perm_map ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + perm_group VARCHAR (1024) , + res_id BIGINT , + group_id BIGINT , + user_id BIGINT , + perm_for INT NOT NULL DEFAULT 0, + perm_type INT NOT NULL DEFAULT 0, + is_recursive INT NOT NULL DEFAULT 0, + is_wild_card TINYINT (1) NOT NULL DEFAULT 1, + grant_revoke TINYINT (1) NOT NULL DEFAULT 1, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_audit_map; +create table x_audit_map ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + res_id BIGINT , + group_id BIGINT , + user_id BIGINT , + audit_type INT NOT NULL DEFAULT 0, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_policy_export_audit; +create table x_policy_export_audit ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + client_ip VARCHAR (255) NOT NULL, + agent_id VARCHAR (255) , + req_epoch BIGINT NOT NULL, + last_updated DATETIME , + repository_name VARCHAR (1024) , + exported_json TEXT , + http_ret_code INT NOT NULL DEFAULT 0, + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists x_trx_log; +create table x_trx_log ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + class_type INT NOT NULL DEFAULT 0, + object_id BIGINT , + parent_object_id BIGINT , + parent_object_class_type INT NOT NULL DEFAULT 0, + parent_object_name VARCHAR (1024) , + object_name VARCHAR (1024) , + attr_name VARCHAR (255) , + prev_val VARCHAR (1024) , + new_val VARCHAR (1024) , + trx_id VARCHAR (1024) , + action VARCHAR (255) , + sess_id VARCHAR (512) , + req_id VARCHAR (30) , + sess_type VARCHAR (30) , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +drop table if exists xa_access_audit; +create table xa_access_audit ( + id BIGINT NOT NULL AUTO_INCREMENT, + create_time DATETIME , + update_time DATETIME , + added_by_id BIGINT , + upd_by_id BIGINT , + audit_type INT NOT NULL DEFAULT 0, + access_result INT DEFAULT 0, + access_type VARCHAR (255) , + acl_enforcer VARCHAR (255) , + agent_id VARCHAR (255) , + client_ip VARCHAR (255) , + client_type VARCHAR (255) , + policy_id BIGINT DEFAULT 0, + repo_name VARCHAR (255) , + repo_type INT DEFAULT 0, + result_reason VARCHAR (255) , + session_id VARCHAR (255) , + event_time DATETIME , + request_user VARCHAR (255) , + action VARCHAR (2000) , + request_data VARCHAR (2000) , + resource_path VARCHAR (2000) , + resource_type VARCHAR (255) , + PRIMARY KEY(id) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + + +ALTER TABLE x_db_base ADD ( + CONSTRAINT x_db_base_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_db_base ADD ( + CONSTRAINT x_db_base_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_auth_sess ADD ( + CONSTRAINT x_auth_sess_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_auth_sess ADD ( + CONSTRAINT x_auth_sess_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_auth_sess ADD ( + CONSTRAINT x_auth_sess_FK_user_id FOREIGN KEY (user_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_portal_user ADD ( + CONSTRAINT x_portal_user_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_portal_user ADD ( + CONSTRAINT x_portal_user_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_portal_user_role ADD ( + CONSTRAINT x_portal_user_role_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_portal_user_role ADD ( + CONSTRAINT x_portal_user_role_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_portal_user_role ADD ( + CONSTRAINT x_portal_user_role_FK_user_id FOREIGN KEY (user_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_asset ADD ( + CONSTRAINT x_asset_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_asset ADD ( + CONSTRAINT x_asset_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_resource ADD ( + CONSTRAINT x_resource_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_resource ADD ( + CONSTRAINT x_resource_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_resource ADD ( + CONSTRAINT x_resource_FK_asset_id FOREIGN KEY (asset_id) + REFERENCES x_asset (id)); +ALTER TABLE x_resource ADD ( + CONSTRAINT x_resource_FK_parent_id FOREIGN KEY (parent_id) + REFERENCES x_resource (id)); +ALTER TABLE x_cred_store ADD ( + CONSTRAINT x_cred_store_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_cred_store ADD ( + CONSTRAINT x_cred_store_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group ADD ( + CONSTRAINT x_group_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group ADD ( + CONSTRAINT x_group_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group ADD ( + CONSTRAINT x_group_FK_cred_store_id FOREIGN KEY (cred_store_id) + REFERENCES x_cred_store (id)); +ALTER TABLE x_user ADD ( + CONSTRAINT x_user_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_user ADD ( + CONSTRAINT x_user_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_user ADD ( + CONSTRAINT x_user_FK_cred_store_id FOREIGN KEY (cred_store_id) + REFERENCES x_cred_store (id)); +ALTER TABLE x_group_users ADD ( + CONSTRAINT x_group_users_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group_users ADD ( + CONSTRAINT x_group_users_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group_users ADD ( + CONSTRAINT x_group_users_FK_p_group_id FOREIGN KEY (p_group_id) + REFERENCES x_group (id)); +ALTER TABLE x_group_users ADD ( + CONSTRAINT x_group_users_FK_user_id FOREIGN KEY (user_id) + REFERENCES x_user (id)); +ALTER TABLE x_group_groups ADD ( + CONSTRAINT x_group_groups_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group_groups ADD ( + CONSTRAINT x_group_groups_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_group_groups ADD ( + CONSTRAINT x_group_groups_FK_p_group_id FOREIGN KEY (p_group_id) + REFERENCES x_group (id)); +ALTER TABLE x_group_groups ADD ( + CONSTRAINT x_group_groups_FK_group_id FOREIGN KEY (group_id) + REFERENCES x_group (id)); +ALTER TABLE x_perm_map ADD ( + CONSTRAINT x_perm_map_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_perm_map ADD ( + CONSTRAINT x_perm_map_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_perm_map ADD ( + CONSTRAINT x_perm_map_FK_res_id FOREIGN KEY (res_id) + REFERENCES x_resource (id)); +ALTER TABLE x_perm_map ADD ( + CONSTRAINT x_perm_map_FK_group_id FOREIGN KEY (group_id) + REFERENCES x_group (id)); +ALTER TABLE x_perm_map ADD ( + CONSTRAINT x_perm_map_FK_user_id FOREIGN KEY (user_id) + REFERENCES x_user (id)); +ALTER TABLE x_audit_map ADD ( + CONSTRAINT x_audit_map_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_audit_map ADD ( + CONSTRAINT x_audit_map_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_audit_map ADD ( + CONSTRAINT x_audit_map_FK_res_id FOREIGN KEY (res_id) + REFERENCES x_resource (id)); +ALTER TABLE x_audit_map ADD ( + CONSTRAINT x_audit_map_FK_group_id FOREIGN KEY (group_id) + REFERENCES x_group (id)); +ALTER TABLE x_audit_map ADD ( + CONSTRAINT x_audit_map_FK_user_id FOREIGN KEY (user_id) + REFERENCES x_user (id)); +ALTER TABLE x_policy_export_audit ADD ( + CONSTRAINT x_policy_export_audit_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_policy_export_audit ADD ( + CONSTRAINT x_policy_export_audit_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_trx_log ADD ( + CONSTRAINT x_trx_log_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE x_trx_log ADD ( + CONSTRAINT x_trx_log_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE xa_access_audit ADD ( + CONSTRAINT xa_access_audit_FK_added_by_id FOREIGN KEY (added_by_id) + REFERENCES x_portal_user (id)); +ALTER TABLE xa_access_audit ADD ( + CONSTRAINT xa_access_audit_FK_upd_by_id FOREIGN KEY (upd_by_id) + REFERENCES x_portal_user (id)); + +ALTER TABLE x_portal_user ADD ( + CONSTRAINT x_portal_user_UK_login_id UNIQUE (login_id(767)) ); +ALTER TABLE x_portal_user ADD ( + CONSTRAINT x_portal_user_UK_email UNIQUE (email(512)) ); + +ALTER TABLE x_db_base ADD (INDEX x_db_base_cr_time (create_time)); +ALTER TABLE x_db_base ADD (INDEX x_db_base_up_time (update_time)); +ALTER TABLE x_auth_sess ADD (INDEX x_auth_sess_cr_time (create_time)); +ALTER TABLE x_auth_sess ADD (INDEX x_auth_sess_up_time (update_time)); +ALTER TABLE x_portal_user ADD (INDEX x_portal_user_cr_time (create_time)); +ALTER TABLE x_portal_user ADD (INDEX x_portal_user_up_time (update_time)); +ALTER TABLE x_portal_user ADD (INDEX x_portal_user_name (first_name(767))); +ALTER TABLE x_portal_user ADD (INDEX x_portal_user_email (email(512))); +ALTER TABLE x_portal_user_role ADD (INDEX x_portal_user_role_cr_time (create_time)); +ALTER TABLE x_portal_user_role ADD (INDEX x_portal_user_role_up_time (update_time)); +ALTER TABLE x_asset ADD (INDEX x_asset_cr_time (create_time)); +ALTER TABLE x_asset ADD (INDEX x_asset_up_time (update_time)); +ALTER TABLE x_resource ADD (INDEX x_resource_cr_time (create_time)); +ALTER TABLE x_resource ADD (INDEX x_resource_up_time (update_time)); +ALTER TABLE x_cred_store ADD (INDEX x_cred_store_cr_time (create_time)); +ALTER TABLE x_cred_store ADD (INDEX x_cred_store_up_time (update_time)); +ALTER TABLE x_group ADD (INDEX x_group_cr_time (create_time)); +ALTER TABLE x_group ADD (INDEX x_group_up_time (update_time)); +ALTER TABLE x_user ADD (INDEX x_user_cr_time (create_time)); +ALTER TABLE x_user ADD (INDEX x_user_up_time (update_time)); +ALTER TABLE x_group_users ADD (INDEX x_group_users_cr_time (create_time)); +ALTER TABLE x_group_users ADD (INDEX x_group_users_up_time (update_time)); +ALTER TABLE x_group_groups ADD (INDEX x_group_groups_cr_time (create_time)); +ALTER TABLE x_group_groups ADD (INDEX x_group_groups_up_time (update_time)); +ALTER TABLE x_perm_map ADD (INDEX x_perm_map_cr_time (create_time)); +ALTER TABLE x_perm_map ADD (INDEX x_perm_map_up_time (update_time)); +ALTER TABLE x_audit_map ADD (INDEX x_audit_map_cr_time (create_time)); +ALTER TABLE x_audit_map ADD (INDEX x_audit_map_up_time (update_time)); +ALTER TABLE x_policy_export_audit ADD (INDEX x_policy_export_audit_cr_time (create_time)); +ALTER TABLE x_policy_export_audit ADD (INDEX x_policy_export_audit_up_time (update_time)); +ALTER TABLE x_trx_log ADD (INDEX x_trx_log_cr_time (create_time)); +ALTER TABLE x_trx_log ADD (INDEX x_trx_log_up_time (update_time)); +ALTER TABLE xa_access_audit ADD (INDEX xa_access_audit_cr_time (create_time)); +ALTER TABLE xa_access_audit ADD (INDEX xa_access_audit_up_time (update_time)); +SET SQL_MODE=@OLD_SQL_MODE; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; +##champlain changes +ALTER TABLE `x_group` ADD `group_src` INT NOT NULL DEFAULT 0; +ALTER TABLE `x_resource` ADD `policy_name` VARCHAR( 500 ) NULL DEFAULT NULL; +ALTER TABLE `x_resource` ADD UNIQUE `x_resource_UK_policy_name` ( `policy_name` ); +ALTER TABLE `x_resource` ADD `res_topologies` TEXT NULL DEFAULT NULL ; +ALTER TABLE `x_resource` ADD `res_services` TEXT NULL DEFAULT NULL; +ALTER TABLE `x_perm_map` ADD `ip_address` TEXT NULL DEFAULT NULL; +ALTER TABLE `x_asset` CHANGE `config` `config` LONGTEXT NULL DEFAULT NULL ; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/patches/001-groupsource.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/patches/001-groupsource.sql b/security-admin/db/mysql/patches/001-groupsource.sql new file mode 100644 index 0000000..c49d8cb --- /dev/null +++ b/security-admin/db/mysql/patches/001-groupsource.sql @@ -0,0 +1,34 @@ +-- 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_group_source_column_to_x_group_table; + +delimiter ;; + create procedure add_group_source_column_to_x_group_table() begin + + /* add group source column if not exist */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_group') then + if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_group' and column_name = 'group_src') then + ALTER TABLE `x_group` ADD `group_src` INT NOT NULL DEFAULT 0; + end if; + end if; + +end;; + +delimiter ; + + call add_group_source_column_to_x_group_table(); + + drop procedure if exists add_group_source_column_to_x_group_table; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/patches/002-policyname.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/patches/002-policyname.sql b/security-admin/db/mysql/patches/002-policyname.sql new file mode 100644 index 0000000..35927f5 --- /dev/null +++ b/security-admin/db/mysql/patches/002-policyname.sql @@ -0,0 +1,37 @@ +-- 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_policy_name_column_to_x_resource_table; + +delimiter ;; +create procedure add_policy_name_column_to_x_resource_table() begin + + /* add policy name column if not exist */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource') then + if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource' and column_name = 'policy_name') then + ALTER TABLE `x_resource` ADD `policy_name` VARCHAR( 500 ) NULL DEFAULT NULL; + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource' and column_name = 'policy_name') then + ALTER TABLE `x_resource` ADD UNIQUE `x_resource_UK_policy_name` ( `policy_name` ); + end if; + end if; + end if; + + +end;; + +delimiter ; +call add_policy_name_column_to_x_resource_table(); + +drop procedure if exists add_policy_name_column_to_x_resource_table; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/patches/003-knoxrepo.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/patches/003-knoxrepo.sql b/security-admin/db/mysql/patches/003-knoxrepo.sql new file mode 100644 index 0000000..04c050a --- /dev/null +++ b/security-admin/db/mysql/patches/003-knoxrepo.sql @@ -0,0 +1,48 @@ +-- 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_columns_for_knox_repository; + +delimiter ;; +create procedure add_columns_for_knox_repository() begin + + /* add res_topologies if not exist */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource') then + if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource' and column_name = 'res_topologies') then + ALTER TABLE `x_resource` ADD `res_topologies` TEXT NULL DEFAULT NULL ; + end if; + end if; + + /* add res_services if not exist */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource') then + if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_resource' and column_name = 'res_services') then + ALTER TABLE `x_resource` ADD `res_services` TEXT NULL DEFAULT NULL; + end if; + end if; + + /* add ip_address if not exist */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_perm_map') then + if not exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_perm_map' and column_name = 'ip_address') then + ALTER TABLE `x_perm_map` ADD `ip_address` TEXT NULL DEFAULT NULL; + end if; + end if; + + +end;; + +delimiter ; +call add_columns_for_knox_repository(); + +drop procedure if exists add_columns_for_knox_repository; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/patches/004-assetconfigsize.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/patches/004-assetconfigsize.sql b/security-admin/db/mysql/patches/004-assetconfigsize.sql new file mode 100644 index 0000000..bec992b --- /dev/null +++ b/security-admin/db/mysql/patches/004-assetconfigsize.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 change_config_column_datatype_of_x_asset_table; + +delimiter ;; +create procedure change_config_column_datatype_of_x_asset_table() begin + + /* change config data type to longtext if not exist */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_asset' and column_name = 'config' and data_type='text') then + ALTER TABLE `x_asset` CHANGE `config` `config` MEDIUMTEXT NULL DEFAULT NULL ; + end if; + +end;; + +delimiter ; +call change_config_column_datatype_of_x_asset_table(); + +drop procedure if exists change_config_column_datatype_of_x_asset_table; http://git-wip-us.apache.org/repos/asf/incubator-ranger/blob/9c2f0d1f/security-admin/db/mysql/patches/005-xtrxlogcolumnsize.sql ---------------------------------------------------------------------- diff --git a/security-admin/db/mysql/patches/005-xtrxlogcolumnsize.sql b/security-admin/db/mysql/patches/005-xtrxlogcolumnsize.sql new file mode 100644 index 0000000..4ec9a6d --- /dev/null +++ b/security-admin/db/mysql/patches/005-xtrxlogcolumnsize.sql @@ -0,0 +1,34 @@ +-- 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 change_values_columns_datatype_of_x_trx_log_table; + +delimiter ;; +create procedure change_values_columns_datatype_of_x_trx_log_table() begin + + /* change prev_value column data type to mediumtext */ + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_trx_log' and column_name = 'prev_val' and data_type='varchar') then + ALTER TABLE `x_trx_log` CHANGE `prev_val` `prev_val` MEDIUMTEXT NULL DEFAULT NULL ; + end if; + if exists (select * from information_schema.columns where table_schema=database() and table_name = 'x_trx_log' and column_name = 'new_val' and data_type='varchar') then + ALTER TABLE `x_trx_log` CHANGE `new_val` `new_val` MEDIUMTEXT NULL DEFAULT NULL ; + end if; + +end;; + +delimiter ; +call change_values_columns_datatype_of_x_trx_log_table(); + +drop procedure if exists change_values_columns_datatype_of_x_trx_log_table;
