Skip to content

Commit

Permalink
README setup instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-north committed Feb 22, 2018
1 parent cd84deb commit 6e07133
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 4 deletions.
23 changes: 23 additions & 0 deletions POSTGRES_SETUP.md
Original file line number Diff line number Diff line change
@@ -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.
77 changes: 77 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions SQLITE_SETUP.md
Original file line number Diff line number Diff line change
@@ -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
14 changes: 10 additions & 4 deletions scripts/test/ex/index.sh
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -15,5 +21,5 @@ function exerciseFilter() {
echo $str
}

filter=$(exerciseFilter $1)
npm run test -- "EX$filter:" $2 $3 $4
filter=$(exerciseFilter $1):
npm run test -- $filter $2 $3 $4

0 comments on commit 6e07133

Please sign in to comment.