diff options
| -rwxr-xr-x | getmepostgres.sh | 59 | ||||
| -rw-r--r-- | package.json | 1 | ||||
| -rwxr-xr-x | runmepostgres.sh | 8 | ||||
| -rw-r--r-- | src/db/model/User.ts | 17 |
4 files changed, 53 insertions, 32 deletions
diff --git a/getmepostgres.sh b/getmepostgres.sh index 50976f8..cb0388a 100755 --- a/getmepostgres.sh +++ b/getmepostgres.sh @@ -1,26 +1,27 @@ #!/bin/bash -echo "> Checking for postgres at ~/pg"; -if [ -d "~/pg" ]; then +PGDIR=${1-"$HOME/pg"} + +echo "> Checking for postgres at $PGDIR"; +if [ -d "$PGDIR" ]; then echo "Postgres Directory exists, nevermind..."; exit 1; fi -echo " "; -echo " "; -echo " "; +echo; +echo; +echo; echo "This installation process takes ~3:50 minutes to complete."; -echo " "; -echo " "; -echo " "; -sleep 3; +echo; +echo; +echo; -echo "> Making postgres directory at ~/pg"; -mkdir ~/pg; +echo "> Making postgres directory at $PGDIR"; +mkdir -p "$PGDIR"; currentDir=$(pwd); -echo "> Chaning dir to ~/pg"; -cd ~/pg; +echo "> Changing dir to $PGDIR"; +cd "$PGDIR"; echo "> Cloning Repo"; git clone https://github.com/postgres/postgres.git; @@ -30,34 +31,34 @@ cd ./postgres; git reset --hard REL_10_1; echo "> Configuring"; -./configure --prefix=$HOME/pg/postgres/ --with-python PYTHON=/usr/bin/python2.7; +./configure --prefix="$PWD" --with-python PYTHON="/usr/bin/python2.7"; echo "> Building Postgres"; -make -j 5; +make; echo "> Installing Postgres"; make install; echo "> Initialise the Database"; -~/pg/postgres/bin/initdb -D ~/pg/postgres/data/; -echo " "; -echo " "; -echo " "; -echo " "; +"$PGDIR/postgres/bin/initdb" -D "$PGDIR/postgres/data/"; +echo; +echo; +echo; +echo; echo "> Starting the postgres server"; -~/pg/postgres/bin/pg_ctl -D ~/pg/postgres/data/ -l POSTGRES_logfile start; +"$PGDIR/postgres/bin/pg_ctl" -D "$PGDIR/postgres/data/" -l POSTGRES_logfile start; echo "> Create the Database"; -~/pg/postgres/bin/createdb be4; +"$PGDIR/postgres/bin/createdb" be4; echo "> Creating Admin user"; -~/pg/postgres/bin/psql -U ${USER} postgres -c "CREATE USER admin WITH PASSWORD 'eprprJacR0hBpmWvs5IDJZTnjRAY2gM3tSm0b1af';"; +"$PGDIR/postgres/bin/psql" -U ${USER} postgres -c "CREATE USER admin WITH PASSWORD 'eprprJacR0hBpmWvs5IDJZTnjRAY2gM3tSm0b1af';"; echo "> Granting Admin Permissions"; -~/pg/postgres/bin/psql -U ${USER} postgres -c "ALTER DATABASE be4 OWNER TO admin;"; +"$PGDIR/postgres/bin/psql" -U ${USER} postgres -c "ALTER DATABASE be4 OWNER TO admin;"; -echo " "; -echo " "; -echo " "; -echo " "; -echo " "; +echo; +echo; +echo; +echo; +echo; echo "> Completed the installation of Postgres."; cd $currentDir; diff --git a/package.json b/package.json index 2f9c6fd..6bf1a30 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@types/express": "^4.0.33", "@types/morgan": "^1.7.32", "@types/node": "^6.0.46", + "@types/sequelize": "^4.27.5", "body-parser": "^1.18.2", "express": "^4.16.2", "morgan": "^1.9.0", diff --git a/runmepostgres.sh b/runmepostgres.sh index 632ea66..b5dd29c 100755 --- a/runmepostgres.sh +++ b/runmepostgres.sh @@ -1,8 +1,10 @@ #!/bin/bash +PGDIR=${1-"$HOME/pg"} + read -p "Press [Enter] key to start Postgres (will already be running if you just got it) use ctl+c to cancel"; echo "> Starting Server"; -~/pg/postgres/bin/pg_ctl -D ~/pg/postgres/data/ -l POSTGRES_logfile start; +"$PGDIR/postgres/bin/pg_ctl" -D "$PGDIR/postgres/data/" -l POSTGRES_logfile start; -#echo "> Conecting as admin user: " + ${USER}; -#~/pg/postgres/bin/psql -U ${USER} postgres; +echo "> Conecting as admin user: " + ${USER}; +~/pg/postgres/bin/psql -U ${USER} postgres; diff --git a/src/db/model/User.ts b/src/db/model/User.ts new file mode 100644 index 0000000..8a3fc1d --- /dev/null +++ b/src/db/model/User.ts @@ -0,0 +1,17 @@ +import { + Table, + Column +} from 'sequelize-typescript'; + +@Table +class User extends Model<User> { + @Column + @PrimaryKey + username: string; + + @Column + password: string; + + @CreatedAt + creationDate: Date; +} |
