I just started a new project with postgres, Git bash, node and react. I installed postgres, git bash, started working in the back-end code and decided to handle sql scripts via bash script. I thought I configured everything correctly, system path for bash and postgres and a global configure npm run command. ideally npm run configure should drop the existing DB for the project, recreate it, create all the new tables, etc. but the script never finishes running at the point of dropping the database it just stops and it doesn't do anything else.
Important note: I'm working in a windows 10 environment.
troubleshooting done:
- confirmed the environment variables for postgres and paths
- made sure configure_db.sh was an executable file
- made sure that the user node_user was a super user in postgres with sufficient permissions
- ran the file by executing the file instead of the npm command
- removed the drop/createdb commands from the script to see if at least I could create tables but it does the same thing, it runs the echo line and it stays there.
Git Bash terminal output:
Leo@Leon5677-LAPTOP MINGW64 /
$ cd c:/workspace/DataStack/backend/bin/sql
Leo@Leon5677-LAPTOP MINGW64 /c/workspace/DataStack/backend/bin/sql
$ ls -l
total 3
-rwxr-xr-x 1 Leo 197121 318 Nov 29 15:22 configure_db.sh*
-rw-r--r-- 1 Leo 197121 231 Nov 23 18:05 task.sql
-rw-r--r-- 1 Leo 197121 105 Nov 23 17:58 plan.sql
Leonardo Sanchez@Leon5677-LAPTOP MINGW64 /c/workspace/DataStack/backend/bin/sql
$ npm run configure
> backend@1.0.0 configure C:\workspace\DataStack\backend
> sh ./bin/sql/configure_db.sh
configuring DataStack
script:
#!/bin/bash
export PGPASSWORD= 'password'
echo "configuring DataStack"
dropdb -U node_user DataStack
createdb -U node_user DataStack
psql -U node_user datastackdb< ./bin/sql/plan.sql
psql -U node_user datastackdb< ./bin/sql/task.sql
echo "DataStack was configured"
Comments
Post a Comment