diff --git a/POSTGRES_SETUP.md b/POSTGRES_SETUP.md new file mode 100644 index 00000000..193606d9 --- /dev/null +++ b/POSTGRES_SETUP.md @@ -0,0 +1,23 @@ +# Setting up PostgreSQL + +## OS X + +### Option 1 - Postgres.app + +Download and run [Postgres.app](https://postgresapp.com/) -- a free-standing database server that's super easy to install and start. Grab [pgAdmin](https://www.pgadmin.org/download/pgadmin-4-macos/) and install it. + +### Option 2 - Homebrew + +1. First, make sure you have homebrew installed +2. Run `brew doctor` and address anything homebrew wants you to fix +3. Run `brew install postgresql` +4. Grab [pgAdmin](https://www.pgadmin.org/download/pgadmin-4-macos/) and install it. + +## Windows + +1. Grab the [the appropriate windows installer](https://www.postgresql.org/download/windows/) and run it. +2. Put the DLLs in your `C:\WINDOWS\system32` folder + +## Linux + +Use `apt-get` or equivalent. diff --git a/README.md b/README.md index 90093f62..afc32724 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,83 @@ Here's what it looks like (and [here](https://damp-oasis-38940.herokuapp.com/) i This app is not in a good state at the beginning of the workshop. Features are missing, there are major performances, and quite a few database-related bugs. We'll fix all these problems and learn as we go! +# Setup Instructions + +## Clone this project + +In your terminal, run + +```sh +git clone https://github.com/mike-works/sql-fundamentals sql +cd sql +``` + +## Database Setup + +This project is used for two workshops. [SQL Fundamentals](https://mike.works/course/sql-fundamentals-ad811af) may be completed using either SQLite or PostgreSQL, and [Professional SQL](https://mike.works/course/professional-sql-c9c7184) requires PostgreSQL. + +To set up the database software, please check out these guides + +* [Installing SQLite 3](./SQLITE_SETUP.md) +* [Installing Postgres 10](./POSTGRES_SETUP.md) + +## Install dependencies + +If you only intend to complete the [SQL Fundamentals](https://mike.works/course/sql-fundamentals-ad811af) workshop (exercises 1-10), you can run + +```sh +npm install --no-optional +``` + +If you wish to proceed beyond exercise 10 for the [Professional SQL](https://mike.works/course/professional-sql-c9c7184) course, please include optional dependencies + +```sh +npm install +``` + +## Seed Data + +If you're using the _SQLite_ database, the `./master.sqlite` file already contains the data we'll be working with. Please run + +```sh +npm run db:setup:sqlite +``` + +If you're using the _PostgreSQL_ database, the `./northwind.sql` script contains the necessary commands for setting up the equivalent data. Please run + +```sh +npm run db:setup:pg +``` + +## Run the tests + +There's an initial set of tests that ensure the app is correctly setup for the beginning of the course. You should be able to run this command and see them all passing + +```sh +# Test against SQLite +npm run test:ex 0 +# Test against PostgreSQL +DB_TYPE=pg npm run test:ex 0 +``` + +Or, if you wish to have the app watch the source code for changes, and re-run the tests on each save... + +```sh +# Test against SQLite +npm run test:ex:watch 0 +# Test against PostgreSQL +DB_TYPE=pg npm run test:ex:watch 0 +``` + +## Start the app + +```sh +# Run w/ SQLite +npm run watch +# Run w/ PostgreSQL +DB_TYPE=pg npm run watch +``` + # Deploy this app on heroku If you don't want to set up your own [PostgreSQL](https://www.postgresql.org) database locally, you can deploy this app onto heroku and use their $7/month hosted PostgreSQL service. diff --git a/SQLITE_SETUP.md b/SQLITE_SETUP.md new file mode 100644 index 00000000..47f50315 --- /dev/null +++ b/SQLITE_SETUP.md @@ -0,0 +1,22 @@ +# Setting up SQLite + +## OS X + +The easiest way to install SQLite on OS X is to use [homebrew](https://brew.sh/). + +1. First, make sure you have homebrew installed +2. Run `brew doctor` and address anything homebrew wants you to fix +3. Run `brew install sqlite` + +## Windows + +1. Grab the [precompiled windows DLLs from the SQLite website](https://www.sqlite.org/download.html#win32). Make sure to also get the _sqlite-tools_ package so you have a CLI that can run in `cmd.exe` +2. Put the DLLs in your `C:\WINDOWS\system32` folder + +## Linux + +Please run + +`sudo apt-get install sqlite3 libsqlite3-dev` + +or the equivalent on your operating system diff --git a/scripts/test/ex/index.sh b/scripts/test/ex/index.sh index 9b141aeb..3996ee61 100755 --- a/scripts/test/ex/index.sh +++ b/scripts/test/ex/index.sh @@ -1,7 +1,13 @@ #!/usr/bin/env sh function exerciseFilter() { - num=$1 - str="$1" + num=$1; + str="EX"; + if [ $num -ge 10 ] + then + str=$str$num; + else + str=$str"0$num"; + fi while [ $num -ge 1 ] do num=`expr $num - 1` @@ -15,5 +21,5 @@ function exerciseFilter() { echo $str } -filter=$(exerciseFilter $1) -npm run test -- "EX$filter:" $2 $3 $4 \ No newline at end of file +filter=$(exerciseFilter $1): +npm run test -- $filter $2 $3 $4 \ No newline at end of file