summaryrefslogtreecommitdiffstats
path: root/standalone
diff options
context:
space:
mode:
authorguochuyicmri <guochuyi@chinamobile.com>2019-04-16 22:37:26 +0800
committerguochuyicmri <guochuyi@chinamobile.com>2019-04-16 22:37:28 +0800
commit209c7f2cc8678cbb67b9e9f46f2893a7e0c422c9 (patch)
tree135dabd18290b0abf5e1f677fc886e8d06ef11d3 /standalone
parent2ab776ce04fd45c07d8918fdcb131b9b123250e5 (diff)
Upgrade uui-server database to postgreSQL
Change-Id: I693d644b01817e2a16f82113567bcfd57e78feda Issue-ID: USECASEUI-236 Signed-off-by: guochuyicmri <guochuyi@chinamobile.com>
Diffstat (limited to 'standalone')
-rw-r--r--standalone/src/main/assembly/bin/run.sh2
-rw-r--r--standalone/src/main/assembly/resources/bin/initDB.sh16
-rw-r--r--standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createdb.sql31
-rw-r--r--standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql133
-rw-r--r--standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql14
5 files changed, 15 insertions, 181 deletions
diff --git a/standalone/src/main/assembly/bin/run.sh b/standalone/src/main/assembly/bin/run.sh
index 679fc208..a80b0b01 100644
--- a/standalone/src/main/assembly/bin/run.sh
+++ b/standalone/src/main/assembly/bin/run.sh
@@ -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"
diff --git a/standalone/src/main/assembly/resources/bin/initDB.sh b/standalone/src/main/assembly/resources/bin/initDB.sh
index 8c4cc8b8..baa06724 100644
--- a/standalone/src/main/assembly/resources/bin/initDB.sh
+++ b/standalone/src/main/assembly/resources/bin/initDB.sh
@@ -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
index 004a717a..00000000
--- a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createdb.sql
+++ /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
index 59d51a80..00000000
--- a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql
+++ /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;
-
diff --git a/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql b/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql
index a62d0835..b158bc61 100644
--- a/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql
+++ b/standalone/src/main/assembly/resources/dbscripts/postgres/uui_create_table.sql
@@ -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,