diff --git metastore/scripts/upgrade/derby/022-HIVE-10239.derby.sql metastore/scripts/upgrade/derby/022-HIVE-10239.derby.sql new file mode 100644 index 0000000..6a36d75 --- /dev/null +++ metastore/scripts/upgrade/derby/022-HIVE-10239.derby.sql @@ -0,0 +1,5 @@ +ALTER TABLE "APP"."SERDE_PARAMS" ALTER COLUMN "PARAM_KEY" set data type varchar(800); + +CREATE TABLE "APP"."TEST_TABLE_HIVE10239" ("ID" BIGINT NOT NULL, "COL_NAME" VARCHAR(128)); + +ALTER TABLE "APP"."TEST_TABLE_HIVE10239" ADD CONSTRAINT "TEST_TABLE_HIVE10239_PK" PRIMARY KEY ("ID"); diff --git metastore/scripts/upgrade/derby/hive-schema-1.2.0.derby.sql metastore/scripts/upgrade/derby/hive-schema-1.2.0.derby.sql index cdb85e1..6653ed5 100644 --- metastore/scripts/upgrade/derby/hive-schema-1.2.0.derby.sql +++ metastore/scripts/upgrade/derby/hive-schema-1.2.0.derby.sql @@ -24,7 +24,7 @@ CREATE TABLE "APP"."DATABASE_PARAMS" ("DB_ID" BIGINT NOT NULL, "PARAM_KEY" VARCH CREATE TABLE "APP"."TBL_COL_PRIVS" ("TBL_COLUMN_GRANT_ID" BIGINT NOT NULL, "COLUMN_NAME" VARCHAR(128), "CREATE_TIME" INTEGER NOT NULL, "GRANT_OPTION" SMALLINT NOT NULL, "GRANTOR" VARCHAR(128), "GRANTOR_TYPE" VARCHAR(128), "PRINCIPAL_NAME" VARCHAR(128), "PRINCIPAL_TYPE" VARCHAR(128), "TBL_COL_PRIV" VARCHAR(128), "TBL_ID" BIGINT); -CREATE TABLE "APP"."SERDE_PARAMS" ("SERDE_ID" BIGINT NOT NULL, "PARAM_KEY" VARCHAR(256) NOT NULL, "PARAM_VALUE" VARCHAR(4000)); +CREATE TABLE "APP"."SERDE_PARAMS" ("SERDE_ID" BIGINT NOT NULL, "PARAM_KEY" VARCHAR(800) NOT NULL, "PARAM_VALUE" VARCHAR(4000)); CREATE TABLE "APP"."COLUMNS_V2" ("CD_ID" BIGINT NOT NULL, "COMMENT" VARCHAR(4000), "COLUMN_NAME" VARCHAR(128) NOT NULL, "TYPE_NAME" VARCHAR(4000), "INTEGER_IDX" INTEGER NOT NULL); @@ -108,6 +108,8 @@ CREATE TABLE "APP"."NOTIFICATION_LOG" ("NL_ID" BIGINT NOT NULL, "DB_NAME" VARCHA CREATE TABLE "APP"."NOTIFICATION_SEQUENCE" ("NNI_ID" BIGINT NOT NULL, "NEXT_EVENT_ID" BIGINT NOT NULL); +CREATE TABLE "APP"."TEST_TABLE_HIVE10239" ("ID" BIGINT NOT NULL, "COL_NAME" VARCHAR(128)); + -- ---------------------------------------------- -- DDL Statements for indexes -- ---------------------------------------------- @@ -237,6 +239,8 @@ ALTER TABLE "APP"."NOTIFICATION_LOG" ADD CONSTRAINT "NOTIFICATION_LOG_PK" PRIMAR ALTER TABLE "APP"."NOTIFICATION_SEQUENCE" ADD CONSTRAINT "NOTIFICATION_SEQUENCE_PK" PRIMARY KEY ("NNI_ID"); +ALTER TABLE "APP"."TEST_TABLE_HIVE10239" ADD CONSTRAINT "TEST_TABLE_HIVE10239_PK" PRIMARY KEY ("ID"); + -- foreign ALTER TABLE "APP"."IDXS" ADD CONSTRAINT "IDXS_FK1" FOREIGN KEY ("ORIG_TBL_ID") REFERENCES "APP"."TBLS" ("TBL_ID") ON DELETE NO ACTION ON UPDATE NO ACTION; diff --git metastore/scripts/upgrade/derby/upgrade-1.1.0-to-1.2.0.derby.sql metastore/scripts/upgrade/derby/upgrade-1.1.0-to-1.2.0.derby.sql index 4aadbbc..590a28e 100644 --- metastore/scripts/upgrade/derby/upgrade-1.1.0-to-1.2.0.derby.sql +++ metastore/scripts/upgrade/derby/upgrade-1.1.0-to-1.2.0.derby.sql @@ -1,3 +1,5 @@ -- Upgrade MetaStore schema from 1.1.0 to 1.2.0 +RUN '022-HIVE-10239.derby.sql'; + UPDATE "APP".VERSION SET SCHEMA_VERSION='1.2.0', VERSION_COMMENT='Hive release version 1.2.0' where VER_ID=1; diff --git metastore/scripts/upgrade/oracle/022-HIVE-10239.oracle.sql metastore/scripts/upgrade/oracle/022-HIVE-10239.oracle.sql new file mode 100644 index 0000000..c5bc933 --- /dev/null +++ metastore/scripts/upgrade/oracle/022-HIVE-10239.oracle.sql @@ -0,0 +1,9 @@ +alter table SERDE_PARAMS modify PARAM_KEY varchar2(800); + +CREATE TABLE TEST_TABLE_HIVE10239 +( + ID NUMBER NOT NULL, + COL_NAME VARCHAR2(128) +); + +ALTER TABLE TEST_TABLE_HIVE10239 ADD CONSTRAINT TEST_TABLE_HIVE10239_PK PRIMARY KEY (ID); diff --git metastore/scripts/upgrade/oracle/hive-schema-1.2.0.oracle.sql metastore/scripts/upgrade/oracle/hive-schema-1.2.0.oracle.sql index 4027425..c5a95cb 100644 --- metastore/scripts/upgrade/oracle/hive-schema-1.2.0.oracle.sql +++ metastore/scripts/upgrade/oracle/hive-schema-1.2.0.oracle.sql @@ -324,7 +324,7 @@ ALTER TABLE ROLE_MAP ADD CONSTRAINT ROLE_MAP_PK PRIMARY KEY (ROLE_GRANT_ID); CREATE TABLE SERDE_PARAMS ( SERDE_ID NUMBER NOT NULL, - PARAM_KEY VARCHAR2(256) NOT NULL, + PARAM_KEY VARCHAR2(800) NOT NULL, PARAM_VALUE VARCHAR2(4000) NULL ); @@ -572,6 +572,14 @@ CREATE TABLE NOTIFICATION_SEQUENCE ALTER TABLE NOTIFICATION_SEQUENCE ADD CONSTRAINT NOTIFICATION_SEQUENCE_PK PRIMARY KEY (NNI_ID); +CREATE TABLE TEST_TABLE_HIVE10239 +( + ID NUMBER NOT NULL, + COL_NAME VARCHAR2(128), +); + +ALTER TABLE TEST_TABLE_HIVE10239 ADD CONSTRAINT TEST_TABLE_HIVE10239_PK PRIMARY KEY (ID); + -- Constraints for table PART_COL_PRIVS for class(es) [org.apache.hadoop.hive.metastore.model.MPartitionColumnPrivilege] diff --git metastore/scripts/upgrade/oracle/upgrade-1.1.0-to-1.2.0.oracle.sql metastore/scripts/upgrade/oracle/upgrade-1.1.0-to-1.2.0.oracle.sql index d507c2b..c2716a4 100644 --- metastore/scripts/upgrade/oracle/upgrade-1.1.0-to-1.2.0.oracle.sql +++ metastore/scripts/upgrade/oracle/upgrade-1.1.0-to-1.2.0.oracle.sql @@ -1,4 +1,6 @@ SELECT 'Upgrading MetaStore schema from 1.1.0 to 1.2.0' AS Status from dual; +@022-HIVE-10239.oracle.sql + UPDATE VERSION SET SCHEMA_VERSION='1.2.0', VERSION_COMMENT='Hive release version 1.2.0' where VER_ID=1; SELECT 'Finished upgrading MetaStore schema from 1.1.0 to 1.2.0' AS Status from dual; diff --git metastore/scripts/upgrade/postgres/022-HIVE-10239.postgres.sql metastore/scripts/upgrade/postgres/022-HIVE-10239.postgres.sql new file mode 100644 index 0000000..a792280 --- /dev/null +++ metastore/scripts/upgrade/postgres/022-HIVE-10239.postgres.sql @@ -0,0 +1,8 @@ +alter table "SERDE_PARAMS" alter column "PARAM_KEY" type VARCHAR(800); + +CREATE TABLE "TEST_TABLE_HIVE10239" +( + "ID" BIGINT NOT NULL, + "COL_NAME" VARCHAR(128), + PRIMARY KEY ("ID") +); diff --git metastore/scripts/upgrade/postgres/hive-schema-1.2.0.postgres.sql metastore/scripts/upgrade/postgres/hive-schema-1.2.0.postgres.sql index 1377ad8..90e0d16 100644 --- metastore/scripts/upgrade/postgres/hive-schema-1.2.0.postgres.sql +++ metastore/scripts/upgrade/postgres/hive-schema-1.2.0.postgres.sql @@ -342,7 +342,7 @@ CREATE TABLE "SERDES" ( CREATE TABLE "SERDE_PARAMS" ( "SERDE_ID" bigint NOT NULL, - "PARAM_KEY" character varying(256) NOT NULL, + "PARAM_KEY" character varying(800) NOT NULL, "PARAM_VALUE" character varying(4000) DEFAULT NULL::character varying ); @@ -598,6 +598,13 @@ CREATE TABLE "NOTIFICATION_SEQUENCE" PRIMARY KEY ("NNI_ID") ); +CREATE TABLE "TEST_TABLE_HIVE10239" +( + "ID" BIGINT NOT NULL, + "COL_NAME" VARCHAR(128), + PRIMARY KEY ("ID") +); + -- -- Name: BUCKETING_COLS_pkey; Type: CONSTRAINT; Schema: public; Owner: hiveuser; Tablespace: -- diff --git metastore/scripts/upgrade/postgres/upgrade-1.1.0-to-1.2.0.postgres.sql metastore/scripts/upgrade/postgres/upgrade-1.1.0-to-1.2.0.postgres.sql index 9b9b4c2..e0291d2 100644 --- metastore/scripts/upgrade/postgres/upgrade-1.1.0-to-1.2.0.postgres.sql +++ metastore/scripts/upgrade/postgres/upgrade-1.1.0-to-1.2.0.postgres.sql @@ -1,5 +1,6 @@ SELECT 'Upgrading MetaStore schema from 1.1.0 to 1.2.0'; +\i 022-HIVE-10239.postgres.sql; UPDATE "VERSION" SET "SCHEMA_VERSION"='1.2.0', "VERSION_COMMENT"='Hive release version 1.2.0' where "VER_ID"=1; SELECT 'Finished upgrading MetaStore schema from 1.1.0 to 1.2.0'; diff --git testutils/metastore/dbs/derby/execute.sh testutils/metastore/dbs/derby/execute.sh new file mode 100755 index 0000000..d60f05b --- /dev/null +++ testutils/metastore/dbs/derby/execute.sh @@ -0,0 +1,37 @@ +#!/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. + +# This script executes all hive metastore upgrade scripts on an specific +# database server in order to verify that upgrade scripts are working +# properly. + +cd $(dirname $1) + +echo "####################################################" +echo "Executing script for Derby SQL: $1" +echo "####################################################" + +export DERBY_HOME=/usr/share/javadb +export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 +export PATH=$PATH:$DERBY_HOME/bin:$JAVA_HOME/bin +export CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar:$DERBY_HOME/lib/derbyclient.jar + +echo "connect 'jdbc:derby:/tmp/hive_hms_testing;create=true';" > /tmp/derbyRun.sql +echo "run '$1';" >> /tmp/derbyRun.sql +echo "quit;" >> /tmp/derbyRun.sql + +ij /tmp/derbyRun.sql diff --git testutils/metastore/dbs/derby/prepare.sh testutils/metastore/dbs/derby/prepare.sh new file mode 100755 index 0000000..fe4b2c3 --- /dev/null +++ testutils/metastore/dbs/derby/prepare.sh @@ -0,0 +1,63 @@ +#!/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. + +# This script executes all hive metastore upgrade scripts on an specific +# database server in order to verify that upgrade scripts are working +# properly. + +export DEBIAN_FRONTEND=noninteractive +OS_VERSION=`lsb_release -c | cut -d":" -f2` + +echo "####################################################" +echo "Begin for OS version $OS_VERSION" +echo "####################################################" + +HTTPS_INFO=($(dpkg -l apt-transport-https | grep ^i | tr -s ' ')) +if [[ ${HTTPS_INFO[1]} == "apt-transport-https" ]] +then + echo "apt-transport-https package installed" +else + echo "apt-transport-https package not installed" + apt-get install -y --force-yes apt-transport-https +fi + +INSTALL_INFO=($(dpkg -l \*javadb-core\* | grep ^ii | tr -s ' ')) + +if [[ ${INSTALL_INFO[1]} == "sun-javadb-core" ]] +then + echo "Derby already installed...Skipping" +else + echo "Derby not installed" + # Cleanup existing installation + configuration. + apt-get purge -y --force-yes derby-tools sun-javadb-client sun-javadb-core sun-javadb-common libderby-java openjdk-7-jre openjdk-7-jre openjdk-7-jre-headless || /bin/true + echo "####################################################" + echo "Installing Derby dependencies:" + echo "####################################################" + apt-get update || /bin/true + apt-get install -y --force-yes -o Dpkg::Options::="--force-overwrite" sun-javadb-core sun-javadb-client derby-tools +fi + +export DERBY_HOME=/usr/share/javadb +export JAVA_HOME=//usr/lib/jvm/java-7-openjdk-amd64 +export PATH=$PATH:/usr/share/javadb/bin:$JAVA_HOME/bin +export CLASSPATH=$CLASSPATH:$DERBY_HOME/lib/derby.jar:$DERBY_HOME/lib/derbytools.jar:$DERBY_HOME/lib/derbyclient.jar +rm -rf /tmp/hive_hms_testing; + +echo "connect 'jdbc:derby:/tmp/hive_hms_testing;create=true';" > /tmp/derbyInit.sql +ij /tmp/derbyInit.sql + +echo "DONE!!!" + diff --git testutils/metastore/dbs/oracle/execute.sh testutils/metastore/dbs/oracle/execute.sh new file mode 100755 index 0000000..d63bf42 --- /dev/null +++ testutils/metastore/dbs/oracle/execute.sh @@ -0,0 +1,31 @@ +#!/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. + +# This script executes all hive metastore upgrade scripts on an specific +# database server in order to verify that upgrade scripts are working +# properly. + +cd $(dirname $1) + +echo "####################################################" +echo "Executing script for Oracle: $1" +echo "####################################################" + +export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server +export PATH=$PATH:$ORACLE_HOME/bin + +echo quit | sqlplus -L hiveuser/hivepw@XE @$1 diff --git testutils/metastore/dbs/oracle/prepare.sh testutils/metastore/dbs/oracle/prepare.sh new file mode 100755 index 0000000..795d505 --- /dev/null +++ testutils/metastore/dbs/oracle/prepare.sh @@ -0,0 +1,92 @@ +#!/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. + +# This script executes all hive metastore upgrade scripts on an specific +# database server in order to verify that upgrade scripts are working +# properly. + +# Cleanup existing installation + configuration. +echo "####################################################" +echo "Detecting any existing Oracle XE installation:" +echo "####################################################" + +apt-get clean + +HTTPS_INFO=($(dpkg -l apt-transport-https | grep ^i | tr -s ' ')) +if [[ ${HTTPS_INFO[1]} == "apt-transport-https" ]] +then + echo "apt-transport-https package installed" +else + echo "apt-transport-https package not installed" + apt-get install -y --force-yes apt-transport-https +fi + +INSTALL_INFO=($(dpkg -l oracle\* | grep ^i | tr -s ' ')) + +if [[ ${INSTALL_INFO[1]} == "oracle-xe" ]] && [[ ${INSTALL_INFO[2]} == 10.2* ]] +then + echo "Oracle XE already installed...Skipping" +else + echo "Oracle XE not installed or is of a different version" + apt-get purge -y --force-yes oracle-xe || /bin/true + echo "####################################################" + echo "Installing Oracle XE dependencies:" + echo "####################################################" + if grep -q "deb http://oss.oracle.com/debian unstable main non-free" /etc/apt/sources.list.d/oracle-xe.list + then + echo "Sources already listed" + else + echo "deb http://oss.oracle.com/debian unstable main non-free" > /etc/apt/sources.list.d/oracle-xe.list + fi + + wget http://oss.oracle.com/el4/RPM-GPG-KEY-oracle -O- | sudo apt-key add - || /bin/true + apt-get update || /bin/true + ls -al /var/cache/apt/archives + apt-get install -y --force-yes oracle-xe:i386 +fi + +echo "####################################################" +echo "Configuring Oracle XE Environment:" +echo "####################################################" +echo "8080" > /tmp/silent.properties +echo "1521" >> /tmp/silent.properties +echo "hivepw" >> /tmp/silent.properties +echo "hivepw" >> /tmp/silent.properties +echo "y" >> /tmp/silent.properties + +/etc/init.d/oracle-xe configure < /tmp/silent.properties > /tmp/silentInstall.log || /bin/true + +export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server +export PATH=$PATH:$ORACLE_HOME/bin + +echo "####################################################" +echo "Setting up user account and Table space:" +echo "####################################################" +echo "drop user hiveuser cascade;" > /tmp/oraInit.sql +echo "alter database default tablespace SYSTEM;" >> /tmp/oraInit.sql +echo "drop tablespace hive_tbspace including contents and datafiles;" >> /tmp/oraInit.sql + +echo "create user hiveuser identified by hivepw;" >> /tmp/oraInit.sql +echo "grant connect to hiveuser;" >> /tmp/oraInit.sql +echo "grant create table to hiveuser;" >> /tmp/oraInit.sql +echo "create smallfile tablespace hive_tbspace datafile 'hive.dbf' size 100m;" >> /tmp/oraInit.sql +echo "alter database default tablespace hive_tbspace;" >> /tmp/oraInit.sql +echo "alter user hiveuser quota 100m on hive_tbspace;" >> /tmp/oraInit.sql +echo "exit;" >> /tmp/oraInit.sql + +sqlplus -L SYSTEM/hivepw@XE @/tmp/oraInit.sql + +echo "DONE!!!" diff --git testutils/metastore/dbs/postgres/execute.sh testutils/metastore/dbs/postgres/execute.sh new file mode 100755 index 0000000..cabcae4 --- /dev/null +++ testutils/metastore/dbs/postgres/execute.sh @@ -0,0 +1,29 @@ +#!/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. + +# This script executes all hive metastore upgrade scripts on an specific +# database server in order to verify that upgrade scripts are working +# properly. + +cd $(dirname $1) + +echo "####################################################" +echo "Executing script for PostgreSQL: $1" +echo "####################################################" + +export PGPASSWORD=hivepw +psql -h localhost -U hiveuser -d hive_hms_testing -f $1 diff --git testutils/metastore/dbs/postgres/prepare.sh testutils/metastore/dbs/postgres/prepare.sh new file mode 100755 index 0000000..2036354 --- /dev/null +++ testutils/metastore/dbs/postgres/prepare.sh @@ -0,0 +1,72 @@ +#!/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. + +# This script executes all hive metastore upgrade scripts on an specific +# database server in order to verify that upgrade scripts are working +# properly. + +export DEBIAN_FRONTEND=noninteractive +OS_VERSION=`lsb_release -c | cut -d":" -f2` +echo "$OS_VERSION" + +echo "####################################################" +echo "Begin for OS version $OS_VERSION" +echo "####################################################" + +HTTPS_INFO=($(dpkg -l apt-transport-https | grep ^i | tr -s ' ')) +if [[ ${HTTPS_INFO[1]} == "apt-transport-https" ]] +then + echo "apt-transport-https package installed" +else + echo "apt-transport-https package not installed" + apt-get install -y --force-yes apt-transport-https +fi + +INSTALL_INFO=($(dpkg -l postgresql-9.4\* | grep ^i | tr -s ' ')) + +if [[ ${INSTALL_INFO[1]} == "postgresql-9.4" ]] +then + echo "PostgreSQL already installed...Skipping" +else + echo "PostgreSQL not installed" + # Cleanup existing installation + configuration. + apt-get purge -y --force-yes postgressql-9.4 || /bin/true + echo "####################################################" + echo "Installing PostgreSQL dependencies:" + echo "####################################################" + if grep -q "deb http://apt.postgresql.org/pub/repos/apt/ $OS_VERSION-pgdg main" /etc/apt/sources.list.d/postgreSQL.list + then + echo "Sources already listed" + else + echo "deb http://apt.postgresql.org/pub/repos/apt/ $OS_VERSION-pgdg main" >> /etc/apt/sources.list.d/postgreSQL.list + fi + + wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - + apt-get update || /bin/true + apt-get install -y --force-yes postgresql-9.4 +fi + +echo "####################################################" +echo "Configuring PostgreSQL Environment:" +echo "####################################################" +echo "drop database if exists hive_hms_testing;" > /tmp/postgresInit.sql +echo "drop user if exists hiveuser;" >> /tmp/postgresInit.sql +echo "create user hiveuser createdb createuser password 'hivepw';" >> /tmp/postgresInit.sql +echo "create database hive_hms_testing owner hiveuser;" >> /tmp/postgresInit.sql +sudo -u postgres psql -f /tmp/postgresInit.sql + +echo "DONE!!!" +