Change the DB Script to Accommodate DCAE 83/22083/2
authorGuangrong Fu <fu.guangrong@zte.com.cn>
Sat, 4 Nov 2017 03:40:13 +0000 (11:40 +0800)
committerGuangrong Fu <fu.guangrong@zte.com.cn>
Sat, 4 Nov 2017 04:02:23 +0000 (12:02 +0800)
Change-Id: If47a0ef564cf252c461e60d4aff4021ebc24d25a
Issue-ID: HOLMES-81
Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
rulemgt-standalone/src/main/assembly/bin/initDB.sh
rulemgt-standalone/src/main/assembly/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql

index 60b1f77..b52b228 100644 (file)
@@ -24,6 +24,11 @@ port=$4
 host=$5
 echo "start init holmes rulemgt db"
 main_path=$HOME/..
+
+sed -i "s|DBNAME|$dbname|g" "$main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql"
+sed -i "s|DBUSER|$user|g" "$main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql"
+sed -i "s|DBPWD|$password|g" "$main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql"
+
 cat $main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql
 echo "dbname=$dbname"
 echo "user=$user"
@@ -31,7 +36,7 @@ echo "password=$password"
 echo "port=$port"
 echo "host=$host"
 export PGPASSWORD=$password
-psql -U $user -p $port -h $host -f $main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql
+psql -U $user -p $port -h $host -d $dbname -f $main_path/dbscripts/postgresql/onap-holmes_rulemgt-createobj.sql
 psql -U $user -p $port -h $host -d $dbname --command 'select * from aplus_rule;'
 sql_result=$?
 unset PGPASSWORD
index cbd3c59..87dd3a7 100644 (file)
 -- See the License for the specific language governing permissions and
 -- limitations under the License.
 --
-/******************drop old database and user***************************/
-\c postgres;
-
-DROP DATABASE IF EXISTS holmes;
-
-DROP ROLE IF EXISTS holmes;
+\c postgres
 
 /******************CREATE NEW DATABASE AND USER***************************/
-CREATE DATABASE holmes;
+CREATE DATABASE DBNAME;
 
-CREATE ROLE holmes with PASSWORD 'holmespwd' LOGIN;
+CREATE ROLE DBUSER with PASSWORD 'DBPWD' LOGIN;
 
 \encoding UTF8;
 
 /******************DELETE OLD TABLE AND CREATE NEW***************************/
-\c holmes;
+\c DBNAME;
+
+DROP TABLE IF EXISTS APLUS_RULE;
 
 CREATE TABLE APLUS_RULE (
   RID VARCHAR(30) NOT NULL,
@@ -58,5 +55,5 @@ CREATE INDEX IDX_APLUS_RULE_TEMPLATEID ON APLUS_RULE (TEMPLATEID);
 CREATE INDEX IDX_APLUS_RULE_ENGINEID ON APLUS_RULE (ENGINEID);
 CREATE INDEX IDX_APLUS_RULE_ENGINETYPE ON APLUS_RULE (ENGINETYPE);
 
-GRANT ALL PRIVILEGES ON APLUS_RULE TO holmes;
+GRANT ALL PRIVILEGES ON APLUS_RULE TO DBUSER;