Upgrade uui-server database to postgreSQL 82/85482/1
authorguochuyicmri <guochuyi@chinamobile.com>
Tue, 16 Apr 2019 14:37:26 +0000 (22:37 +0800)
committerguochuyicmri <guochuyi@chinamobile.com>
Tue, 16 Apr 2019 14:37:28 +0000 (22:37 +0800)
Change-Id: I693d644b01817e2a16f82113567bcfd57e78feda
Issue-ID: USECASEUI-236
Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
standalone/src/main/assembly/bin/run.sh
standalone/src/main/assembly/resources/bin/initDB.sh
standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createdb.sql [deleted file]
standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql [deleted file]
standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql

index 679fc20..a80b0b0 100644 (file)
@@ -25,7 +25,7 @@ sleep 10
 echo "usecase-ui database init script start..."
 dbScript="$main_path/resources/bin/initDB.sh"
 chmod 755 $dbScript
-source $dbScript 127.0.0.1 5432 postgres postgres postgres
+source $dbScript 127.0.0.1 5432 postgres uui
 echo "usecase-ui database init script finished normally..."
 
 JAVA_PATH="$JAVA_HOME/bin/java"
index 8c4cc8b..baa0672 100644 (file)
@@ -19,20 +19,19 @@ echo "setting database init parameters"
 main_path="/home/uui"
 host=$1
 port=$2
-dbname=$3
-user=$4
-password=$5
+user_pg=$3
+user_uui=$4
 
 echo "setting postgres database password"
 su - $user <<EOF
-psql --command "alter user $user with password '$password';"
+psql --command "alter user $user_pg with password '$user_pg';"
 EOF
 
 echo "start create usecase-ui database..."
 dbscripts_path="$main_path/resources/dbscripts/postgres"
-psql "host=$host port=$port user=$user password=$password dbname=$dbname" -f $dbscripts_path/uui_create_db.sql
+psql "host=$host port=$port user=$user_pg password=$user_pg dbname=$user_pg" -f $dbscripts_path/uui_create_db.sql
 sql_result=$?
-if [ $sql_result!=0 ]; then
+if [ $sql_result -ne 0 ]; then
     echo "failed to create usecase-ui database!"
     exit 1
 else
@@ -40,12 +39,11 @@ else
 fi
 
 echo "start create usecase-ui tables..."
-psql "host=$host port=$port user=$user password=$password dbname=$dbname" -f $dbscripts_path/uui_create_table.sql
+psql "host=$host port=$port user=$user_uui password=$user_uui dbname=$user_uui" -f $dbscripts_path/uui_create_table.sql
 sql_result=$?
-if [ $sql_result!=0 ]; then
+if [ $sql_result -ne 0 ]; then
     echo "failed to create usecase-ui table!"
     exit 1
 else
     echo "usecase-ui tables created successfully!"
 fi
-exit 0
diff --git a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createdb.sql b/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createdb.sql
deleted file mode 100644 (file)
index 004a717..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
---
--- Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
---
--- Licensed 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 old database and user***************************/
-use mysql;
-drop database IF EXISTS uui;
-delete from user where User='usecaseui';
-FLUSH PRIVILEGES;
-
-/******************create new database and user***************************/
-create database uui CHARACTER SET utf8;
-
-GRANT ALL PRIVILEGES ON uui.* TO 'uui'@'%' IDENTIFIED BY 'uui' WITH GRANT OPTION;
-GRANT ALL PRIVILEGES ON mysql.* TO 'uui'@'%' IDENTIFIED BY 'uui' WITH GRANT OPTION;
-
-GRANT ALL PRIVILEGES ON uui.* TO 'uui'@'localhost' IDENTIFIED BY 'uui' WITH GRANT OPTION;
-GRANT ALL PRIVILEGES ON mysql.* TO 'uui'@'localhost' IDENTIFIED BY 'uui' WITH GRANT OPTION;
-FLUSH PRIVILEGES; 
\ No newline at end of file
diff --git a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql b/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql
deleted file mode 100644 (file)
index 59d51a8..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
---
--- Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
---
--- Licensed 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.
---
-
-use uui;
-
-SET FOREIGN_KEY_CHECKS=0;
-
--- ----------------------------
--- Table structure for `alarms_additionalinformation`
--- ----------------------------
-DROP TABLE IF EXISTS `alarms_additionalinformation`;
-CREATE TABLE `alarms_additionalinformation` (
-  `id` int(10) NOT NULL AUTO_INCREMENT,
-  `headerId` varchar(100) NOT NULL,
-  `name` varchar(500) DEFAULT NULL,
-  `value` varchar(500) DEFAULT NULL,
-  `sourceId` varchar(500) DEFAULT NULL,
-  `startEpochMicrosec` varchar(500) DEFAULT NULL,
-  `lastEpochMicroSec` varchar(500) DEFAULT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-ALTER TABLE `alarms_additionalinformation` ADD INDEX `alarms_additionalinformation_index` (`headerId`, `sourceId`);
-
-
--- ----------------------------
--- Table structure for `alarms_commoneventheader`
--- ----------------------------
-DROP TABLE IF EXISTS `alarms_commoneventheader`;
-CREATE TABLE `alarms_commoneventheader` (
-  `id` varchar(100) NOT NULL,
-  `version` varchar(500) DEFAULT NULL,
-  `eventName` varchar(500) DEFAULT NULL,
-  `domain` varchar(500) DEFAULT NULL,
-  `eventId` varchar(500) DEFAULT NULL,
-  `eventType` varchar(500) DEFAULT NULL,
-  `nfcNamingCode` varchar(500) DEFAULT NULL,
-  `nfNamingCode` varchar(500) DEFAULT NULL,
-  `sourceId` varchar(500) DEFAULT NULL,
-  `sourceName` varchar(500) DEFAULT NULL,
-  `reportingEntityId` varchar(500) DEFAULT NULL,
-  `reportingEntityName` varchar(500) DEFAULT NULL,
-  `priority` varchar(50) DEFAULT NULL,
-  `startEpochMicrosec` varchar(500) DEFAULT NULL,
-  `lastEpochMicroSec` varchar(500) DEFAULT NULL,
-  `startEpochMicrosecCleared` varchar(255) DEFAULT NULL,
-  `lastEpochMicroSecCleared` varchar(255) DEFAULT NULL,
-  `sequence` varchar(500) DEFAULT NULL,
-  `faultFieldsVersion` varchar(500) DEFAULT NULL,
-  `eventServrity` varchar(500) DEFAULT NULL,
-  `eventSourceType` varchar(500) DEFAULT NULL,
-  `eventCategory` varchar(500) DEFAULT NULL,
-  `alarmCondition` varchar(500) DEFAULT NULL,
-  `specificProblem` varchar(500) DEFAULT NULL,
-  `vfStatus` varchar(500) DEFAULT NULL,
-  `alarmInterfaceA` varchar(500) DEFAULT NULL,
-  `status` varchar(50) DEFAULT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-ALTER TABLE `alarms_commoneventheader` ADD INDEX `alarms_commoneventheader_index` (`sourceId`);
-
-
--- ----------------------------
--- Table structure for `performance_additionalinformation`
--- ----------------------------
-DROP TABLE IF EXISTS `performance_additionalinformation`;
-CREATE TABLE `performance_additionalinformation` (
-  `id` int(10) NOT NULL AUTO_INCREMENT,
-  `headerId` varchar(100) NOT NULL,
-  `name` varchar(500) DEFAULT NULL,
-  `value` varchar(500) DEFAULT NULL,
-  `sourceId` varchar(500) DEFAULT NULL,
-  `startEpochMicrosec` varchar(500) DEFAULT NULL,
-  `lastEpochMicroSec` varchar(500) DEFAULT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-ALTER TABLE `performance_additionalinformation` ADD INDEX `performance_additionalinformation_index` (`headerId`, `sourceId`);
-
-
--- ----------------------------
--- Table structure for `performance_commoneventheader`
--- ----------------------------
-DROP TABLE IF EXISTS `performance_commoneventheader`;
-CREATE TABLE `performance_commoneventheader` (
-  `id` varchar(100) NOT NULL,
-  `version` varchar(500) DEFAULT NULL,
-  `eventName` varchar(500) DEFAULT NULL,
-  `domain` varchar(500) DEFAULT NULL,
-  `eventId` varchar(500) DEFAULT NULL,
-  `eventType` varchar(500) DEFAULT NULL,
-  `nfcNamingCode` varchar(500) DEFAULT NULL,
-  `nfNamingCode` varchar(500) DEFAULT NULL,
-  `sourceId` varchar(500) DEFAULT NULL,
-  `sourceName` varchar(500) DEFAULT NULL,
-  `reportingEntityId` varchar(500) DEFAULT NULL,
-  `reportingEntityName` varchar(500) DEFAULT NULL,
-  `priority` varchar(50) DEFAULT NULL,
-  `startEpochMicrosec` varchar(500) DEFAULT NULL,
-  `lastEpochMicroSec` varchar(500) DEFAULT NULL,
-  `sequence` varchar(500) DEFAULT NULL,
-  `measurementsForVfScalingVersion` varchar(500) DEFAULT NULL,
-  `measurementInterval` varchar(500) DEFAULT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-ALTER TABLE `performance_commoneventheader` ADD INDEX `performance_commoneventheader_index` (`sourceId`);
--- ----------------------------
--- Table structure for service_instances
--- ----------------------------
-DROP TABLE IF EXISTS `service_instances`;
-CREATE TABLE `service_instances`  (
-  `id` varchar(100) NOT NULL,
-  `serviceInstanceId` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `customerId` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `serviceType` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `serviceDomain` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `operationId` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `parentServiceInstanceId` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  `status` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-
index a62d083..b158bc6 100644 (file)
@@ -17,7 +17,7 @@
 -- ----------------------------
 -- Table structure for "alarms_additionalinformation"
 -- ----------------------------
-DROP TABLE alarms_additionalinformation;
+DROP TABLE IF EXISTS alarms_additionalinformation;
 CREATE TABLE alarms_additionalinformation(
   id serial,
   "header_id" varchar(50) NOT NULL,
@@ -32,7 +32,7 @@ CREATE TABLE alarms_additionalinformation(
 -- ----------------------------
 -- Table structure for "alarms_commoneventheader"
 -- ----------------------------
-DROP TABLE alarms_commoneventheader;
+DROP TABLE IF EXISTS alarms_commoneventheader;
 CREATE TABLE alarms_commoneventheader (
   "id" varchar(50) NOT NULL,
   "version" varchar(100) DEFAULT NULL,
@@ -67,7 +67,7 @@ CREATE TABLE alarms_commoneventheader (
 -- ----------------------------
 -- Table structure for "performance_additionalinformation"
 -- ----------------------------
-DROP TABLE performance_additionalinformation;
+DROP TABLE IF EXISTS performance_additionalinformation;
 CREATE TABLE performance_additionalinformation (
   id serial,
   "header_id" varchar(50) NOT NULL,
@@ -82,7 +82,7 @@ CREATE TABLE performance_additionalinformation (
 -- ----------------------------
 -- Table structure for "performance_commoneventheader"
 -- ----------------------------
-DROP TABLE performance_commoneventheader;
+DROP TABLE IF EXISTS performance_commoneventheader;
 CREATE TABLE performance_commoneventheader (
   "id" varchar(50) NOT NULL,
   "version" varchar(100) DEFAULT NULL,
@@ -108,7 +108,7 @@ CREATE TABLE performance_commoneventheader (
 -- ----------------------------
 -- Table structure for service_instances
 -- ----------------------------
-DROP TABLE service_instances;
+DROP TABLE IF EXISTS service_instances;
 CREATE TABLE service_instances  (
   "id" varchar(50) NOT NULL,
   "service_instance_id" varchar(100) NOT NULL,
@@ -124,7 +124,7 @@ CREATE TABLE service_instances  (
 -- ----------------------------
 -- Table structure for service_instance_operations
 -- ----------------------------
-DROP TABLE service_instance_operations;
+DROP TABLE IF EXISTS service_instance_operations;
 CREATE TABLE service_instance_operations  (
   "service_instance_id" varchar(100) NOT NULL,
   "operation_id" varchar(100) NOT NULL,
@@ -139,7 +139,7 @@ CREATE TABLE service_instance_operations  (
 -- ----------------------------
 -- Table structure for sort_master
 -- ----------------------------
-DROP TABLE sort_master;
+DROP TABLE IF EXISTS sort_master;
 CREATE TABLE sort_master  (
   "sort_type" varchar(50) NOT NULL,
   "sort_code" varchar(10) NOT NULL,