-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from lalithkota/develop
Modified GCTB according to change on Common G2PConnect Module
- Loading branch information
Showing
18 changed files
with
321 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CREATE TABLE payment_list ( | ||
id integer NOT NULL, | ||
batch_id character varying NOT NULL, | ||
request_id character varying NOT NULL, | ||
request_timestamp timestamp without time zone NOT NULL, | ||
from_fa character varying, | ||
to_fa character varying NOT NULL, | ||
amount character varying NOT NULL, | ||
currency character varying NOT NULL, | ||
status character varying(4) NOT NULL, | ||
file character varying, | ||
error_code character varying(27), | ||
error_msg character varying, | ||
backend_name character varying, | ||
created_at timestamp without time zone NOT NULL, | ||
updated_at timestamp without time zone, | ||
active boolean NOT NULL | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE SEQUENCE payment_list_id_seq | ||
AS integer | ||
START WITH 1 | ||
INCREMENT BY 1 | ||
NO MINVALUE | ||
NO MAXVALUE | ||
CACHE 1; | ||
|
||
ALTER SEQUENCE payment_list_id_seq OWNED BY payment_list.id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE ONLY payment_list ALTER COLUMN id SET DEFAULT nextval('payment_list_id_seq'::regclass); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE ONLY payment_list | ||
ADD CONSTRAINT payment_list_pkey PRIMARY KEY (id); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
## Database Initialization Scripts | ||
|
||
### PostgreSQL | ||
|
||
- Create a new role/user called "gctbuser" and create a new database called "gctbdb", | ||
with "gctbuser" as the owner. | ||
No need to run this step if Postgres was installed through openg2p's deployment script. | ||
```sql | ||
CREATE ROLE gctbuser WITH LOGIN NOSUPERUSER CREATEDB CREATEROLE INHERIT REPLICATION CONNECTION LIMIT -1 PASSWORD 'xxxxxx'; | ||
CREATE DATABASE gctbdb WITH OWNER = gctbuser CONNECTION LIMIT = -1; | ||
``` | ||
- Then run | ||
```sh | ||
DB_HOST="openg2p.sandbox.net" \ | ||
DB_USER_PASSWORD="xxxxxx" \ | ||
./deploy.sh | ||
``` | ||
- The following optional Env vars can also be passed: | ||
- `VERSION="1.0.0"` Do not set this if you want latest version. | ||
- `DB_PORT="5432"` Default is 5432. | ||
- `DB_NAME="mydb"` Default is gctbdb. | ||
- `DB_USER="myuser"` Default is gctbuser. | ||
- `DEPLOY_DDL="false"` Default is true. If false, will not run DDL scripts. | ||
- `DEPLOY_DML="false"` Default is true. If false, will not run DML scripts. | ||
- `LOG_DB_QUERY="true"` Default is false. Logs all Db queries. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/usr/bin/env bash | ||
|
||
echoerr() { | ||
echo "$@" 1>&2 | ||
} | ||
|
||
get_scripts_path() { | ||
dirname "$0" | ||
} | ||
|
||
get_default_version() { | ||
basename $(ls -d1 $(get_scripts_path)/*/ | tail -n 1) | ||
} | ||
|
||
execute_script_in_folder() { | ||
folder_path=$1 | ||
for file in $folder_path/* ; do | ||
if [ -d "$file" ]; then | ||
execute_script_in_folder $file | ||
elif [[ $file == *.sh ]]; then | ||
bash $file | ||
elif [[ $file == *.sql || $file == *.psql ]]; then | ||
if [[ $LOG_DB_QUERY == "true" ]]; then | ||
PGPASSWORD="$DB_USER_PASSWORD" \ | ||
psql \ | ||
-h $DB_HOST \ | ||
-p $DB_PORT \ | ||
-d $DB_NAME \ | ||
-U $DB_USER \ | ||
-a -c "$(envsubst < $file)" | ||
else | ||
PGPASSWORD="$DB_USER_PASSWORD" \ | ||
psql \ | ||
-h $DB_HOST \ | ||
-p $DB_PORT \ | ||
-d $DB_NAME \ | ||
-U $DB_USER \ | ||
-c "$(envsubst < $file)" | ||
fi | ||
fi | ||
done | ||
} | ||
|
||
if [ -z "$VERSION" ]; then | ||
export VERSION=$(get_default_version) | ||
else | ||
export VERSION="${VERSION%/}" | ||
fi | ||
if [ -z "$DB_HOST" ]; then | ||
echoerr "DB_HOST not given!" | ||
exit 1 | ||
fi | ||
if [ -z "$DB_PORT" ]; then | ||
export DB_PORT=5432 | ||
fi | ||
if [ -z "$DB_NAME" ]; then | ||
export DB_NAME="gctbdb" | ||
fi | ||
if [ -z "$DB_USER" ]; then | ||
export DB_USER="gctbuser" | ||
fi | ||
if [ -z "$DB_USER_PASSWORD" ]; then | ||
echoerr "DB_USER_PASSWORD not given!" | ||
exit 1 | ||
fi | ||
if [ -z "$DEPLOY_DDL" ]; then | ||
export DEPLOY_DDL="true" | ||
fi | ||
if [ -z "$DEPLOY_DML" ]; then | ||
export DEPLOY_DML="true" | ||
fi | ||
if [ -z "$LOG_DB_QUERY" ]; then | ||
export LOG_DB_QUERY="false" | ||
fi | ||
|
||
if ! [ -d "$(get_scripts_path)/$VERSION" ]; then | ||
echoerr "Given Version not found!" | ||
exit 1; | ||
fi | ||
|
||
if [[ "$DEPLOY_DDL" == "true" ]]; then | ||
execute_script_in_folder $(get_scripts_path)/$VERSION/ddl | ||
fi | ||
if [[ "$DEPLOY_DML" == "true" ]]; then | ||
execute_script_in_folder $(get_scripts_path)/$VERSION/dml | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.