IP=127.0.0.1
PORT=5432
USERNAME=postgres
export PGPASSWORD="12345678"
psql -h $IP -p $PORT -d postgres -U $USERNAME -c 'create database db_informat2_account_prd'
psql -h $IP -p $PORT -d postgres -U $USERNAME -c 'create database db_informat2_biz_prd_0'
psql -h $IP -p $PORT -d postgres -U $USERNAME -c -d db_informat2_biz_prd_0 'create extension ltree'
psql -h $IP -p $PORT -d db_informat2_account_prd -U $USERNAME -f db/db_informat2_account_prd_init.sql
psql -h $IP -p $PORT -d db_informat2_account_prd -U $USERNAME -f db/db_informat2_account_prd_init2.sql
psql -h $IP -p $PORT -d db_informat2_biz_prd_0 -U $USERNAME -f db/db_informat2_biz_prd_0_init.sql
psql -h $IP -p $PORT -d db_informat2_biz_prd_0 -U $USERNAME -f db/db_informat2_biz_prd_0_init2.sql
count=` ls -lrt db/version |wc -l`
count=$(( (count + 1) / 2 ))
for (( i=2; i<=count; i++ ))
do
   echo "current db file index: $i"
   psql -h $IP -p $PORT -d db_informat2_account_prd -U $USERNAME -f db/version/${i}_account.sql
   psql -h $IP -p $PORT -d db_informat2_biz_prd_0 -U $USERNAME -f db/version/${i}_biz.sql
done
